Skip to content

Commit

Permalink
Split deployment flow and check links
Browse files Browse the repository at this point in the history
  • Loading branch information
kwkwan committed Dec 18, 2023
1 parent 997a1a1 commit 4489802
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 33 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,42 +88,10 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: ${{ github.ref == 'refs/heads/master' }}
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

check_links:
name: Check links
needs:
- build
runs-on: ubuntu-latest
steps:

- name: Download site
uses: actions/download-artifact@v3
with:
name: site.zip
path: .

- name: Unzip
run: unzip site.zip

- name: Restore lychee cache
uses: actions/cache@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-

- name: Run lychee for emails
uses: lycheeverse/[email protected]
with:
args: --no-progress --exclude "(https?)|(file)://" --cache --max-cache-age 1d '_site/**/*.html'
fail: false

- name: Run lychee for links
run: lychee --no-progress --exclude-mail --cache --max-cache-age 1d '_site/**/*.html'
98 changes: 98 additions & 0 deletions .github/workflows/check_links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: check_links

on:
push:
branches:
- main
- staging
pull_request:
repository_dispatch:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
environment:
name: production
url: https://www.ituob.org
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Pages
id: pages
uses: actions/configure-pages@v3

- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1

- name: Use Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true

- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'

- name: Checkout data
uses: actions/checkout@v3
with:
token: ${{ secrets.ITUOB_CI_PAT_TOKEN }}
repository: ituob/itu-ob-data
path: data
ref: ${{ needs.set_environment.outputs.data_branch }}
fetch-depth: 1

- name: Cache relaton
uses: actions/cache@v3
with:
path: relaton
key: ${{ runner.os }}-${{ hashFiles('data/**/*.yaml') }}

- name: Build site
env:
JEKYLL_ENV: production
run: |
make _site
zip -r site.zip _site
- name: Upload site
uses: actions/upload-artifact@v3
with:
name: site.zip
path: site.zip
retention-days: 1

check_links:
name: Check links
runs-on: ubuntu-latest
needs: build
steps:
- name: Download site
uses: actions/download-artifact@v3
with:
name: site.zip
path: .

- name: Unzip
run: unzip site.zip

- name: Restore lychee cache
uses: actions/cache@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-

- name: Run lychee for emails
uses: lycheeverse/[email protected]
with:
args: --no-progress --exclude "(https?)|(file)://" --cache --max-cache-age 1d '_site/**/*.html'
fail: false

- name: Run lychee for links
run: lychee --no-progress --exclude-mail --cache --max-cache-age 1d '_site/**/*.html'

0 comments on commit 4489802

Please sign in to comment.