Skip to content

Commit 50d3a04

Browse files
Copilotdiberry
andcommitted
Fix workflow validation issues - use GitHub API, pin actionlint version, remove invalid package
Co-authored-by: diberry <[email protected]>
1 parent 1ddc86f commit 50d3a04

File tree

4 files changed

+6897
-53
lines changed

4 files changed

+6897
-53
lines changed

.github/workflows/README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ This workflow automatically validates all GitHub Actions workflows in the reposi
2121

2222
**Jobs:**
2323
1. **validate-workflows**: Runs actionlint to check syntax and best practices
24-
2. **check-action-versions**: Uses action-validator to check for outdated versions
25-
3. **detect-outdated-actions**: Extracts and analyzes all actions used in workflows
26-
4. **summary**: Provides a consolidated summary of all validation jobs
24+
2. **detect-outdated-actions**: Extracts and analyzes all actions used in workflows, checks availability, and compares with latest versions
25+
3. **summary**: Provides a consolidated summary of all validation jobs
2726

2827
**Outputs:**
2928
- A downloadable report artifact containing all actions and versions in use
@@ -56,19 +55,6 @@ bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/down
5655
actionlint .github/workflows/*.yml
5756
```
5857

59-
### action-validator
60-
Checks for outdated GitHub Actions versions.
61-
62-
**Installation:**
63-
```bash
64-
npm install -g action-validator
65-
```
66-
67-
**Usage:**
68-
```bash
69-
action-validator .github/workflows/your-workflow.yml
70-
```
71-
7258
## Best Practices
7359

7460
1. **Pin Actions to Specific Versions**: Always use specific commit SHAs or version tags (e.g., `actions/checkout@v4`) instead of branches

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ jobs:
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version: '20'
23-
cache: 'npm'
2423

2524
- name: Install dependencies
26-
run: npm ci
25+
run: npm install
2726

2827
- name: Build project
2928
run: npm run build

.github/workflows/validate-workflows.yml

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ jobs:
2323

2424
- name: Install actionlint
2525
run: |
26-
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
26+
# Download actionlint v1.7.9 (pinned version)
27+
curl -sL https://github.com/rhysd/actionlint/releases/download/v1.7.9/actionlint_1.7.9_linux_amd64.tar.gz -o actionlint.tar.gz
28+
tar xzf actionlint.tar.gz
2729
sudo mv ./actionlint /usr/local/bin/
30+
rm actionlint.tar.gz
2831
actionlint --version
2932
3033
- name: Run actionlint
@@ -33,34 +36,6 @@ jobs:
3336
actionlint -color
3437
continue-on-error: false
3538

36-
check-action-versions:
37-
name: Check Action Versions
38-
runs-on: ubuntu-latest
39-
40-
steps:
41-
- name: Checkout repository
42-
uses: actions/checkout@v4
43-
44-
- name: Setup Node.js
45-
uses: actions/setup-node@v4
46-
with:
47-
node-version: '20'
48-
49-
- name: Install action-validator
50-
run: npm install -g action-validator
51-
52-
- name: Validate action versions
53-
run: |
54-
echo "Checking for outdated GitHub Actions..."
55-
# Find all workflow files and check each one
56-
for workflow in .github/workflows/*.yml .github/workflows/*.yaml; do
57-
if [ -f "$workflow" ]; then
58-
echo "Checking $workflow..."
59-
action-validator "$workflow" || true
60-
fi
61-
done
62-
continue-on-error: true
63-
6439
detect-outdated-actions:
6540
name: Detect Outdated Actions
6641
runs-on: ubuntu-latest
@@ -94,7 +69,9 @@ jobs:
9469
echo "No actions found in workflows"
9570
fi
9671
97-
- name: Check action availability
72+
- name: Check action availability and versions
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9875
run: |
9976
echo "Checking if actions are available on GitHub..."
10077
@@ -103,6 +80,8 @@ jobs:
10380
exit 0
10481
fi
10582
83+
UNAVAILABLE_ACTIONS=""
84+
10685
while IFS= read -r action; do
10786
# Skip local actions (starting with ./)
10887
if [[ "$action" == ./* ]]; then
@@ -116,19 +95,39 @@ jobs:
11695
11796
# Check if action exists
11897
if [[ "$ACTION_PATH" == *"/"* ]]; then
119-
REPO_URL="https://github.com/$ACTION_PATH"
12098
echo "Checking $ACTION_PATH@$ACTION_VERSION..."
12199
122-
# Use GitHub API to check if repo exists (no auth needed for public repos)
123-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$REPO_URL")
100+
# Use GitHub API with authentication for better rate limits
101+
API_URL="https://api.github.com/repos/$ACTION_PATH"
102+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
103+
-H "Authorization: token $GITHUB_TOKEN" \
104+
-H "Accept: application/vnd.github.v3+json" \
105+
"$API_URL")
124106
125107
if [ "$HTTP_CODE" -eq 200 ]; then
126108
echo "✓ Action available: $action"
109+
110+
# Try to fetch latest release for comparison
111+
LATEST_RELEASE=$(curl -s \
112+
-H "Authorization: token $GITHUB_TOKEN" \
113+
-H "Accept: application/vnd.github.v3+json" \
114+
"$API_URL/releases/latest" | grep '"tag_name":' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/' || echo "")
115+
116+
if [ -n "$LATEST_RELEASE" ] && [ "$ACTION_VERSION" != "$LATEST_RELEASE" ]; then
117+
echo " ℹ️ Latest version available: $LATEST_RELEASE (current: $ACTION_VERSION)"
118+
fi
127119
else
128120
echo "✗ Action not found or inaccessible: $action (HTTP $HTTP_CODE)"
121+
UNAVAILABLE_ACTIONS="${UNAVAILABLE_ACTIONS}${action}\n"
129122
fi
130123
fi
131124
done < /tmp/workflow-analysis/unique_actions.txt
125+
126+
if [ -n "$UNAVAILABLE_ACTIONS" ]; then
127+
echo ""
128+
echo "⚠️ Warning: Some actions are unavailable:"
129+
echo -e "$UNAVAILABLE_ACTIONS"
130+
fi
132131
133132
- name: Generate action version report
134133
run: |
@@ -173,7 +172,7 @@ jobs:
173172
summary:
174173
name: Validation Summary
175174
runs-on: ubuntu-latest
176-
needs: [validate-workflows, check-action-versions, detect-outdated-actions]
175+
needs: [validate-workflows, detect-outdated-actions]
177176
if: always()
178177

179178
steps:
@@ -186,6 +185,5 @@ jobs:
186185
echo ""
187186
echo "## Jobs Status:"
188187
echo "- Validate Workflows: ${{ needs.validate-workflows.result }}"
189-
echo "- Check Action Versions: ${{ needs.check-action-versions.result }}"
190188
echo "- Detect Outdated Actions: ${{ needs.detect-outdated-actions.result }}"
191189
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)