Skip to content

Commit 4017425

Browse files
committed
add GH action to auto update GH pages when new release is made
1 parent dfdb363 commit 4017425

File tree

4 files changed

+236
-0
lines changed

4 files changed

+236
-0
lines changed

.github/link-check-config.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^https://img\\.shields\\.io/"
5+
},
6+
{
7+
"pattern": "^https://github\\.com/.+/stargazers$"
8+
},
9+
{
10+
"pattern": "^https://github\\.com/.+/network/members$"
11+
},
12+
{
13+
"pattern": "^https://github\\.com/.+/issues$"
14+
}
15+
],
16+
"httpHeaders": [
17+
{
18+
"urls": ["https://github.com", "https://api.github.com"],
19+
"headers": {
20+
"Accept": "application/vnd.github.v3+json",
21+
"User-Agent": "link-checker"
22+
}
23+
}
24+
],
25+
"retryOn429": true,
26+
"retryCount": 3,
27+
"fallbackHttpStatus": [
28+
400,
29+
401,
30+
403,
31+
404,
32+
408,
33+
429,
34+
500,
35+
502,
36+
503,
37+
504
38+
]
39+
}

.github/workflows/deploy-pages.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Ruby
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: '3.1'
31+
bundler-cache: true
32+
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v4
35+
36+
- name: Build with Jekyll
37+
run: |
38+
bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
39+
env:
40+
JEKYLL_ENV: production
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./_site
46+
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4
50+
51+
- name: Comment on Release
52+
if: github.event_name == 'release'
53+
uses: actions/github-script@v7
54+
with:
55+
script: |
56+
github.rest.issues.createComment({
57+
issue_number: context.payload.release.id,
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
body: `🚀 GitHub Pages has been updated! View the live site: ${{ steps.deployment.outputs.page_url }}`
61+
})
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Progress Badge
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
week_number:
9+
description: 'Week number to update to'
10+
required: true
11+
type: number
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
update-progress:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Extract week number
26+
id: extract_week
27+
run: |
28+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
29+
WEEK_NUMBER="${{ github.event.inputs.week_number }}"
30+
else
31+
TAG_NAME="${{ github.event.release.tag_name }}"
32+
echo "Tag name: $TAG_NAME"
33+
34+
# Extract week number from tag (supports formats like "week-5", "v1.5.0", "1.5.0")
35+
if [[ $TAG_NAME =~ week-([0-9]+) ]]; then
36+
WEEK_NUMBER=${BASH_REMATCH[1]}
37+
elif [[ $TAG_NAME =~ v?[0-9]+\.([0-9]+) ]]; then
38+
WEEK_NUMBER=${BASH_REMATCH[1]}
39+
else
40+
echo "Could not extract week number from tag: $TAG_NAME"
41+
exit 1
42+
fi
43+
fi
44+
45+
echo "Week number: $WEEK_NUMBER"
46+
echo "week_number=$WEEK_NUMBER" >> $GITHUB_OUTPUT
47+
48+
- name: Update README.md
49+
run: |
50+
WEEK_NUMBER="${{ steps.extract_week.outputs.week_number }}"
51+
sed -i "s/Progress-Week%20[0-9]\+%2F52/Progress-Week%20${WEEK_NUMBER}%2F52/g" README.md
52+
sed -i "s/Progress-Week [0-9]\+\/52/Progress-Week ${WEEK_NUMBER}\/52/g" README.md
53+
54+
- name: Update index.md
55+
run: |
56+
WEEK_NUMBER="${{ steps.extract_week.outputs.week_number }}"
57+
sed -i "s/Progress-Week%20[0-9]\+%2F52/Progress-Week%20${WEEK_NUMBER}%2F52/g" index.md
58+
sed -i "s/Progress-Week [0-9]\+\/52/Progress-Week ${WEEK_NUMBER}\/52/g" index.md
59+
60+
- name: Commit changes
61+
run: |
62+
git config --local user.email "action@github.com"
63+
git config --local user.name "GitHub Action"
64+
git add README.md index.md
65+
if git diff --staged --quiet; then
66+
echo "No changes to commit"
67+
else
68+
git commit -m "Update progress badge to week ${{ steps.extract_week.outputs.week_number }}"
69+
git push
70+
fi
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Validate Links
2+
3+
on:
4+
release:
5+
types: [published]
6+
schedule:
7+
# Run weekly on Sundays at 2 AM UTC
8+
- cron: '0 2 * * 0'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
issues: write
14+
15+
jobs:
16+
link-check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Check links in README.md
23+
uses: gaurav-nelson/github-action-markdown-link-check@v1
24+
with:
25+
use-quiet-mode: 'yes'
26+
use-verbose-mode: 'yes'
27+
config-file: '.github/link-check-config.json'
28+
file-path: './README.md'
29+
30+
- name: Check links in index.md
31+
uses: gaurav-nelson/github-action-markdown-link-check@v1
32+
with:
33+
use-quiet-mode: 'yes'
34+
use-verbose-mode: 'yes'
35+
config-file: '.github/link-check-config.json'
36+
file-path: './index.md'
37+
38+
- name: Create issue if links are broken
39+
if: failure()
40+
uses: actions/github-script@v7
41+
with:
42+
script: |
43+
const title = `🔗 Broken links detected - ${new Date().toISOString().split('T')[0]}`;
44+
const body = `
45+
## Broken Links Detected
46+
47+
The automated link checker has found broken links in the repository.
48+
49+
**Triggered by:** ${{ github.event_name }}
50+
**Date:** ${new Date().toISOString()}
51+
52+
Please review the workflow logs for details about which links are broken:
53+
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
54+
55+
---
56+
57+
This issue was automatically created by the link validation workflow.
58+
`;
59+
60+
github.rest.issues.create({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
title: title,
64+
body: body,
65+
labels: ['bug', 'documentation']
66+
});

0 commit comments

Comments
 (0)