feat: update all GitHub Actions workflows from Node.js to Go

Replace Node.js setup, npm install, and node/npm commands with
Go setup, go build, and the new awesome-docker CLI binary in all
four workflow files: pull_request, broken_links, health_report,
and deploy-pages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Julien Bisconti
2026-02-27 23:26:48 +01:00
parent 83211a4923
commit e5d5594775
4 changed files with 55 additions and 115 deletions

View File

@@ -2,7 +2,6 @@ name: Broken Links Report
on: on:
schedule: schedule:
# Run every Saturday at 2 AM UTC
- cron: "0 2 * * 6" - cron: "0 2 * * 6"
workflow_dispatch: workflow_dispatch:
@@ -14,68 +13,37 @@ jobs:
issues: write issues: write
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 - uses: actions/checkout@v4
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # ratchet:actions/setup-node@v6.2.0 - uses: actions/setup-go@v5
with: with:
node-version: lts/* go-version: "1.22"
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # ratchet:actions/cache@v5.0.3 - name: Build
with: run: go build -o awesome-docker ./cmd/awesome-docker
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
- name: Run Link Check - name: Run Link Check
id: link_check id: link_check
run: | run: |
npm test > link_check_output.txt 2>&1 || true ./awesome-docker check > link_check_output.txt 2>&1 || true
if grep -q "❌ ERROR" link_check_output.txt; then if grep -q "broken links" link_check_output.txt; then
echo "has_errors=true" >> $GITHUB_OUTPUT echo "has_errors=true" >> "$GITHUB_OUTPUT"
else else
echo "has_errors=false" >> $GITHUB_OUTPUT echo "has_errors=false" >> "$GITHUB_OUTPUT"
fi fi
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create/Update Issue for Broken Links - name: Create/Update Issue for Broken Links
if: steps.link_check.outputs.has_errors == 'true' if: steps.link_check.outputs.has_errors == 'true'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ratchet:actions/github-script@v8 uses: actions/github-script@v7
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
const output = fs.readFileSync('link_check_output.txt', 'utf8'); const output = fs.readFileSync('link_check_output.txt', 'utf8');
// Extract error information const issueBody = `# Broken Links Detected\n\nThe weekly link check found broken or inaccessible links.\n\n\`\`\`\n${output}\n\`\`\`\n\n## Action Required\n\n- Update the URL if the resource moved\n- Remove the entry if permanently unavailable\n- Add to \`config/exclude.yaml\` if a known false positive\n\n---\n*Auto-generated by broken_links.yml*`;
const errorMatch = output.match(/❌ ERROR[\s\S]*$/);
const errorInfo = errorMatch ? errorMatch[0] : 'Link check failed - see workflow logs';
const issueBody = `# 🔗 Broken Links Detected
The weekly link check has found broken or inaccessible links in the repository.
## Error Details
\`\`\`
${errorInfo}
\`\`\`
## Action Required
Please review and fix the broken links above. Options:
- Update the URL if the resource moved
- Remove the entry if it's permanently unavailable
- Add to \`tests/exclude_in_test.json\` if it's a known false positive
---
*Auto-generated by [broken_links.yml](https://github.com/veggiemonk/awesome-docker/blob/master/.github/workflows/broken_links.yml)*
`;
// Check for existing issue
const issues = await github.rest.issues.listForRepo({ const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -91,21 +59,19 @@ jobs:
issue_number: issues.data[0].number, issue_number: issues.data[0].number,
body: issueBody body: issueBody
}); });
console.log(`Updated issue #${issues.data[0].number}`);
} else { } else {
const issue = await github.rest.issues.create({ await github.rest.issues.create({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
title: '🔗 Broken Links Detected - Action Required', title: 'Broken Links Detected',
body: issueBody, body: issueBody,
labels: ['broken-links', 'bug'] labels: ['broken-links', 'bug']
}); });
console.log(`Created issue #${issue.data.number}`);
} }
- name: Close Issue if No Errors - name: Close Issue if No Errors
if: steps.link_check.outputs.has_errors == 'false' if: steps.link_check.outputs.has_errors == 'false'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ratchet:actions/github-script@v8 uses: actions/github-script@v7
with: with:
script: | script: |
const issues = await github.rest.issues.listForRepo({ const issues = await github.rest.issues.listForRepo({
@@ -115,7 +81,6 @@ jobs:
labels: 'broken-links', labels: 'broken-links',
per_page: 1 per_page: 1
}); });
if (issues.data.length > 0) { if (issues.data.length > 0) {
await github.rest.issues.update({ await github.rest.issues.update({
owner: context.repo.owner, owner: context.repo.owner,
@@ -124,11 +89,4 @@ jobs:
state: 'closed', state: 'closed',
state_reason: 'completed' state_reason: 'completed'
}); });
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issues.data[0].number,
body: '✅ All links are now working! Closing this issue.'
});
console.log(`Closed issue #${issues.data[0].number}`);
} }

View File

@@ -20,22 +20,20 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 uses: actions/checkout@v4
- name: Setup Node.js - uses: actions/setup-go@v5
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # ratchet:actions/setup-node@v6.2.0
with: with:
node-version-file: '.nvmrc' go-version: "1.22"
cache: 'npm'
- name: Install dependencies - name: Build CLI
run: npm ci run: go build -o awesome-docker ./cmd/awesome-docker
- name: Build website - name: Build website
run: npm run build run: ./awesome-docker build
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # ratchet:actions/upload-pages-artifact@v4 uses: actions/upload-pages-artifact@v4
with: with:
path: ./website path: ./website
@@ -48,4 +46,4 @@ jobs:
steps: steps:
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
id: deployment id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # ratchet:actions/deploy-pages@v4 uses: actions/deploy-pages@v4

View File

@@ -2,56 +2,52 @@ name: Weekly Health Report
on: on:
schedule: schedule:
# Run every Monday at 9 AM UTC
- cron: "0 9 * * 1" - cron: "0 9 * * 1"
workflow_dispatch: # Allow manual trigger workflow_dispatch:
jobs: jobs:
health-check: health-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: read
issues: write issues: write
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 - uses: actions/checkout@v4
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # ratchet:actions/setup-node@v6.2.0 - uses: actions/setup-go@v5
with: with:
node-version: lts/* go-version: "1.22"
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # ratchet:actions/cache@v5.0.3 - name: Build
with: run: go build -o awesome-docker ./cmd/awesome-docker
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies - name: Run Health Scoring
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline run: ./awesome-docker health
- name: Run Health Check
run: node tests/health_check.mjs
continue-on-error: true continue-on-error: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Health Report - name: Generate Report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # ratchet:actions/upload-artifact@v5 id: report
with: run: |
name: health-report ./awesome-docker report > health_report.txt 2>&1 || true
path: HEALTH_REPORT.md if [ -s health_report.txt ]; then
echo "has_report=true" >> "$GITHUB_OUTPUT"
else
echo "has_report=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Issue with Health Report - name: Create/Update Issue with Health Report
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ratchet:actions/github-script@v8 if: steps.report.outputs.has_report == 'true'
uses: actions/github-script@v7
with: with:
script: | script: |
const fs = require('fs'); const fs = require('fs');
const report = fs.readFileSync('health_report.txt', 'utf8');
// Read the health report const issueBody = report + '\n\n---\n*Auto-generated weekly by health_report.yml*';
const report = fs.readFileSync('HEALTH_REPORT.md', 'utf8');
// Check if there's already an open issue
const issues = await github.rest.issues.listForRepo({ const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -60,25 +56,19 @@ jobs:
per_page: 1 per_page: 1
}); });
const issueBody = report + '\n\n---\n*This report is auto-generated weekly. See [health_check.mjs](https://github.com/veggiemonk/awesome-docker/blob/master/tests/health_check.mjs) for details.*';
if (issues.data.length > 0) { if (issues.data.length > 0) {
// Update existing issue
await github.rest.issues.update({ await github.rest.issues.update({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issues.data[0].number, issue_number: issues.data[0].number,
body: issueBody body: issueBody
}); });
console.log(`Updated issue #${issues.data[0].number}`);
} else { } else {
// Create new issue await github.rest.issues.create({
const issue = await github.rest.issues.create({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
title: '🏥 Weekly Health Report - Repository Maintenance Needed', title: 'Weekly Health Report - Repository Maintenance Needed',
body: issueBody, body: issueBody,
labels: ['health-report', 'maintenance'] labels: ['health-report', 'maintenance']
}); });
console.log(`Created issue #${issue.data.number}`);
} }

View File

@@ -11,22 +11,16 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2 - uses: actions/checkout@v4
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # ratchet:actions/setup-node@v6.2.0
with:
node-version: lts/*
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # ratchet:actions/cache@v5.0.3 - uses: actions/setup-go@v5
id: cache
with: with:
path: ~/.npm go-version: "1.22"
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies - name: Build
# if: steps.cache.outputs.cache-hit != 'true' run: go build -o awesome-docker ./cmd/awesome-docker
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
- run: npm run test-pr - name: Validate
run: ./awesome-docker validate
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}