Skip to content

Commit a27fb24

Browse files
Patch 16 Add CI/CD Build checks (#22)
Adding 3 scripts - Build antora and Docusaurus on PR to main - Confirmed - Deploy website on merge to main - tennative - Linkchecker to run monthly or manually. - cannot test untill after merge
1 parent 8741059 commit a27fb24

File tree

6 files changed

+10271
-153
lines changed

6 files changed

+10271
-153
lines changed

.github/workflows/build-check.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build Check
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-checks:
12+
concurrency: ci-${{ github.ref }}
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [20.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'yarn'
26+
- name: Install Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: '3.4.1' # Not needed with a .ruby-version, .tool-versions or mise.toml
30+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31+
- name: Install Antora Dependencies
32+
run: |
33+
cd antora
34+
gem install bundler
35+
bundle install
36+
npm install
37+
38+
- name: Install Docusaurus dependencies
39+
run: yarn install
40+
41+
- name: Build website
42+
run: |
43+
cd antora
44+
npx antora antora-playbook.yml --stacktrace
45+
cd ..
46+
yarn build
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build Check
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
deploy:
12+
concurrency: ci-${{ github.ref }}
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'yarn'
26+
- name: Install Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: '3.4.1' # Not needed with a .ruby-version, .tool-versions or mise.toml
30+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31+
- name: Install Antora Dependencies
32+
run: |
33+
cd antora
34+
gem install bundler
35+
bundle install
36+
npm install
37+
38+
- name: Install Docusaurus dependencies
39+
run: yarn install
40+
41+
- name: Build website
42+
run: |
43+
cd antora
44+
npx antora antora-playbook.yml --stacktrace
45+
cd ..
46+
yarn build
47+
48+
- name: Deploy to GitHub Pages
49+
uses: JamesIves/github-pages-deploy-action@v4
50+
with:
51+
folder: build # The folder the action should deploy.

.github/workflows/linkchecker.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Link Checker
2+
env:
3+
WEBSITE_URL: "developer.riscv.org"
4+
5+
# Run this workflow every time a new commit pushed to your repository
6+
on:
7+
# Automatic Schedule Trigger
8+
schedule:
9+
# Run on 1st day of every month
10+
- cron: '0 0 1 * *'
11+
# Manual Trigger
12+
workflow_dispatch:
13+
inputs:
14+
logLevel:
15+
description: 'Log level'
16+
required: true
17+
default: 'warning'
18+
tags:
19+
description: 'Test scenario tags'
20+
21+
jobs:
22+
website-checker:
23+
name: $WEBSITE_URL Link Checker
24+
runs-on: ubuntu-latest
25+
continue-on-error: true
26+
steps:
27+
- name: Install Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.8'
31+
- name: Setup Environment
32+
run: |
33+
pip3 install git+https://github.com/linkchecker/linkchecker.git
34+
mkdir ./logs
35+
36+
- name: Check Links
37+
run: |
38+
linkchecker \
39+
--no-warnings \
40+
-t 100 \
41+
-o html \
42+
--ignore-url /internal/* \
43+
--ignore-url /some_other_directory/~.* \
44+
--ignore-url /*\.extension \
45+
$WEBSITE_URL > ./logs/$WEBSITE_URL.html
46+
47+
- name: Process Link Log
48+
if: always()
49+
continue-on-error: true
50+
run: |
51+
echo LC_SUMMARY=$( awk '/\d* warnings found/' ./logs/$WEBSITE_URL.html) >> $GITHUB_ENV
52+
echo $(awk '/\d* warnings found/' ./logs/$WEBSITE_URL.html )
53+
echo $GITHUB_ENV
54+
55+
- name: Upload Artifact Logs
56+
uses: actions/upload-artifact@v4
57+
if: ${{ always() }}
58+
with:
59+
name: $WEBSITE_URL.html
60+
path: ./logs/$WEBSITE_URL.html
61+
62+
# # Slack Notification of broken links found
63+
# - name: Slack Notification
64+
# uses: rtCamp/action-slack-notify@v2
65+
# if: ${{ failure() }}
66+
# env:
67+
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
68+
# SLACK_CHANNEL: channel_name
69+
# SLACK_USERNAME: Link Checker Bot
70+
# SLACK_TITLE: WARNING - broken links found on $WEBSITE_URL
71+
# MSG_MINIMAL: true
72+
# SLACK_ICON_EMOJI: ':failed:'
73+
# SLACK_MESSAGE: |
74+
# `${{ env.LC_SUMMARY }}`
75+
# link check: broken links detected on $WEBSITE_URL. Please see report artifact.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
antora/build
22
antora/node_modules/
33
antora/yarn.lock
4+
antora/Gemfile.lock
45
.DS_Store
56
.docusaurus
67
build

antora/Gemfile.lock

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)