Skip to content

Commit 3e18226

Browse files
authored
Merge pull request #93 from ray-di/github-actions-workflows
feat: Add comprehensive GitHub Actions workflows for documentation
2 parents 2b30dc9 + 3c9ab51 commit 3e18226

11 files changed

Lines changed: 1061 additions & 68 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Documentation Build and Deploy
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'manuals/**'
8+
- 'llms.txt'
9+
- 'bin/**'
10+
- '_includes/**'
11+
- '_layouts/**'
12+
- 'Gemfile*'
13+
- '_config.yml'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: false
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Ruby
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: 3.2
36+
bundler-cache: true
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: '8.1'
42+
43+
- name: Setup Pages
44+
id: pages
45+
uses: actions/configure-pages@v5
46+
47+
- name: Build Jekyll site
48+
run: |
49+
bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
50+
51+
- name: Copy markdown files for llms.txt compliance
52+
run: ./bin/copy_markdown_files.sh
53+
54+
- name: Generate llms-full.txt
55+
run: php bin/generate_llms_full.php
56+
57+
- name: Generate single-page documentation
58+
run: ruby bin/merge_md_files.rb
59+
60+
- name: Copy generated files to _site
61+
run: |
62+
mkdir -p _site/manuals/1.0/en
63+
mkdir -p _site/manuals/1.0/ja
64+
cp llms-full.txt _site/
65+
cp manuals/1.0/en/1page.md _site/manuals/1.0/en/
66+
cp manuals/1.0/ja/1page.md _site/manuals/1.0/ja/
67+
68+
- name: Upload artifact
69+
uses: actions/upload-pages-artifact@v2
70+
with:
71+
path: "_site/"
72+
73+
deploy:
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.deployment.outputs.page_url }}
77+
runs-on: ubuntu-latest
78+
needs: build
79+
if: github.ref == 'refs/heads/master'
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v5

.github/workflows/link-checker.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: Link Checker
2+
3+
on:
4+
schedule:
5+
# Run weekly on Sundays at 1 AM UTC
6+
- cron: '0 1 * * 0'
7+
workflow_dispatch:
8+
inputs:
9+
check_external:
10+
description: 'Check external links'
11+
required: false
12+
default: 'true'
13+
type: boolean
14+
fail_on_error:
15+
description: 'Fail workflow on broken links'
16+
required: false
17+
default: 'false'
18+
type: boolean
19+
20+
jobs:
21+
link-check:
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.2
31+
bundler-cache: true
32+
33+
- name: Build Jekyll site
34+
run: |
35+
bundle exec jekyll build
36+
37+
- name: Install lychee
38+
run: |
39+
wget -qO- https://github.com/lycheeverse/lychee/releases/latest/download/lychee-x86_64-unknown-linux-gnu.tar.gz | tar -xzv
40+
sudo mv lychee /usr/local/bin/
41+
42+
# Use shared lychee configuration file
43+
44+
- name: Check internal links
45+
run: |
46+
echo "🔍 Checking internal links..."
47+
48+
# Check internal links in built site
49+
lychee --config .lycherc.toml \
50+
--exclude-all-private \
51+
--no-progress \
52+
--offline \
53+
_site/ || {
54+
echo "❌ Internal link check failed"
55+
if [ "${{ github.event.inputs.fail_on_error }}" = "true" ]; then
56+
exit 1
57+
fi
58+
}
59+
60+
echo "✅ Internal link check completed"
61+
62+
- name: Check external links
63+
if: github.event.inputs.check_external != 'false'
64+
run: |
65+
echo "🌐 Checking external links..."
66+
67+
# Create results directory
68+
mkdir -p link-check-results
69+
70+
# Check external links with detailed reporting (excluding generated files)
71+
find manuals -name "*.md" -type f ! -name "1page.md" -exec lychee --config .lycherc.toml \
72+
--no-progress \
73+
--format json \
74+
--output link-check-results/external-links.json \
75+
{} + || {
76+
echo "❌ Some external links are broken"
77+
78+
# Generate human-readable report
79+
echo "## 🔗 Broken External Links Report" > link-check-results/report.md
80+
echo "" >> link-check-results/report.md
81+
echo "The following external links were found to be broken:" >> link-check-results/report.md
82+
echo "" >> link-check-results/report.md
83+
84+
# Parse JSON results for broken links using jq
85+
if [ -f "link-check-results/external-links.json" ]; then
86+
# Install jq for JSON parsing
87+
sudo apt-get update && sudo apt-get install -y jq
88+
89+
# Extract broken links from JSON using jq
90+
jq -r '.links[] | select(.status.status != "Ok") | .url' \
91+
link-check-results/external-links.json | sort -u \
92+
>> link-check-results/broken-links.txt || true
93+
94+
if [ -s "link-check-results/broken-links.txt" ]; then
95+
echo "### Broken Links:" >> link-check-results/report.md
96+
while read -r link; do
97+
echo "- $link" >> link-check-results/report.md
98+
done < link-check-results/broken-links.txt
99+
fi
100+
fi
101+
102+
# Show report
103+
if [ -f "link-check-results/report.md" ]; then
104+
cat link-check-results/report.md
105+
fi
106+
107+
if [ "${{ github.event.inputs.fail_on_error }}" = "true" ]; then
108+
exit 1
109+
fi
110+
}
111+
112+
echo "✅ External link check completed"
113+
114+
- name: Upload link check results
115+
uses: actions/upload-artifact@v3
116+
if: always()
117+
with:
118+
name: link-check-results
119+
path: link-check-results/
120+
retention-days: 30
121+
122+
- name: Create issue for broken links
123+
if: always() && github.event_name == 'schedule'
124+
uses: actions/github-script@v7
125+
with:
126+
script: |
127+
// Check if there's already an open issue for broken links
128+
const { data: issues } = await github.rest.issues.listForRepo({
129+
owner: context.repo.owner,
130+
repo: context.repo.repo,
131+
state: 'open',
132+
labels: ['documentation', 'broken-links']
133+
});
134+
135+
if (issues.length === 0) {
136+
// Create new issue
137+
await github.rest.issues.create({
138+
owner: context.repo.owner,
139+
repo: context.repo.repo,
140+
title: '🔗 Broken links detected in documentation',
141+
body: `
142+
## Broken Links Detected
143+
144+
The scheduled link checker has detected broken links in the documentation.
145+
146+
**Workflow run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
147+
**Date**: ${new Date().toISOString()}
148+
149+
Please check the workflow logs and fix the broken links.
150+
151+
### Actions Required
152+
- [ ] Review the link checker results
153+
- [ ] Fix or remove broken links
154+
- [ ] Update documentation if URLs have changed
155+
- [ ] Close this issue once fixed
156+
157+
This issue was created automatically by the link checker workflow.
158+
`,
159+
labels: ['documentation', 'broken-links', 'automated']
160+
});
161+
}
162+
163+
- name: Create summary
164+
if: always()
165+
run: |
166+
echo "## 🔗 Link Check Summary" >> $GITHUB_STEP_SUMMARY
167+
echo "" >> $GITHUB_STEP_SUMMARY
168+
169+
if [ "${{ job.status }}" = "success" ]; then
170+
echo "✅ All links are working correctly" >> $GITHUB_STEP_SUMMARY
171+
else
172+
echo "❌ Some links are broken" >> $GITHUB_STEP_SUMMARY
173+
echo "" >> $GITHUB_STEP_SUMMARY
174+
echo "Check the workflow logs and uploaded artifacts for details." >> $GITHUB_STEP_SUMMARY
175+
fi
176+
177+
echo "" >> $GITHUB_STEP_SUMMARY
178+
echo "### Configuration" >> $GITHUB_STEP_SUMMARY
179+
echo "- **Check external links**: ${{ github.event.inputs.check_external || 'true' }}" >> $GITHUB_STEP_SUMMARY
180+
echo "- **Fail on error**: ${{ github.event.inputs.fail_on_error || 'false' }}" >> $GITHUB_STEP_SUMMARY
181+
echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)