Skip to content

Commit e0a97e9

Browse files
committed
Add workflow to check for GHA updates
1 parent 8b65e74 commit e0a97e9

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
declare -i update_count=0
8+
9+
tmp="$(mktemp)"
10+
readonly tmp
11+
12+
function cleanup {
13+
rm -f "$tmp"
14+
}
15+
16+
trap cleanup EXIT
17+
18+
set +o errexit
19+
npx actions-up --dry-run > "$tmp" 2>&1
20+
set -o errexit
21+
22+
if grep -Fq 'would be updated' "$tmp"
23+
then
24+
update_count="$(awk '/would be updated/ { print $1 }' "$tmp")"
25+
declare -ri update_count
26+
fi
27+
28+
if (( update_count > 0 ))
29+
then
30+
echo "has-updates=true" >> "$GITHUB_OUTPUT"
31+
echo "update-count=$update_count" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "has-updates=false" >> "$GITHUB_OUTPUT"
34+
echo "update-count=0" >> "$GITHUB_OUTPUT"
35+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check-Actions-Updates
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: '0 16 * * 2' # Runs Tuesdays at 16:00 UTC
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check-actions:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
20+
- id: actions-check
21+
run: ${{ github.workspace }}/.github/scripts/check-actions-updates.sh
22+
- if: steps.actions-check.outputs.has-updates == 'true'
23+
run: |
24+
echo "::error:: Found ${{ steps.actions-check.outputs.update-count }} outdated GitHub Actions. Please update them before merging."
25+
echo "You can update them by running: npx actions-up"
26+
echo "Or manually update the versions in your workflows."
27+
exit 1

0 commit comments

Comments
 (0)