|
| 1 | +name: Zola |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: main |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + zola: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + BASE_URL: https://github.com/getzola/zola/releases/download |
| 13 | + VERS: v0.19.1 |
| 14 | + ARCH: x86_64-unknown-linux-gnu |
| 15 | + # https://github.com/crazy-max/ghaction-github-pages/issues/1#issuecomment-623202206 |
| 16 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - name: Lint |
| 20 | + uses: avto-dev/markdown-lint@v1 |
| 21 | + with: |
| 22 | + args: '.' |
| 23 | + config: '.markdownlint.json' |
| 24 | + - name: Install Zola |
| 25 | + run: | |
| 26 | + curl -L ${BASE_URL}/${VERS}/zola-${VERS}-${ARCH}.tar.gz | tar -xz |
| 27 | + echo "Zola version: $(./zola --version)" |
| 28 | + - name: Zola build |
| 29 | + run: ./zola build |
| 30 | + - name: Upload GitHub Pages artifact |
| 31 | + uses: actions/upload-pages-artifact@v3 |
| 32 | + with: |
| 33 | + path: public |
| 34 | + |
| 35 | + links: |
| 36 | + name: Check for Broken Links |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} |
| 42 | + - name: Get changed files |
| 43 | + id: changed-files |
| 44 | + # source: https://stackoverflow.com/a/74268200, added filtering for markdown files |
| 45 | + run: | |
| 46 | + if ${{ github.event_name == 'pull_request' }}; then |
| 47 | + changed_files=$(git diff --name-only -r HEAD^1 HEAD -z | grep '\.md$' -zZ | xargs -0) |
| 48 | + else |
| 49 | + changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -z | grep '\.md$' -zZ | xargs -0) |
| 50 | + fi |
| 51 | + echo "changed_files: $changed_files" |
| 52 | + echo "changed_files=$changed_files" >> $GITHUB_OUTPUT |
| 53 | + - name: Check links |
| 54 | + uses: lycheeverse/[email protected] |
| 55 | + if: ${{ steps.changed-files.outputs.changed_files != '' }} |
| 56 | + with: |
| 57 | + fail: true |
| 58 | + args: >- |
| 59 | + --verbose |
| 60 | + --no-progress |
| 61 | + --accept '100..=103,200..=299,300..=399' |
| 62 | + --exclude '[^\w]todo[^\w]?' |
| 63 | + --exclude 'https://(www\.|old\.)?reddit\.com' |
| 64 | + --exclude 'https://www.patreon.com' |
| 65 | + --exclude 'https://gamedev.social' |
| 66 | + --exclude 'dev.epicgames.com' |
| 67 | + --exclude-path 'assets/logo/readme.md' |
| 68 | + ${{ steps.changed-files.outputs.changed_files }} |
| 69 | +
|
| 70 | + pages: |
| 71 | + needs: zola |
| 72 | + permissions: |
| 73 | + pages: write |
| 74 | + id-token: write |
| 75 | + environment: |
| 76 | + name: github-pages |
| 77 | + url: ${{ steps.deployment.outputs.page_url }} |
| 78 | + runs-on: ubuntu-latest |
| 79 | + if: format('refs/heads/{0}', github.event.repository.default_branch) == github.ref |
| 80 | + steps: |
| 81 | + - name: Deploy to GitHub Pages |
| 82 | + id: deployment |
| 83 | + uses: actions/deploy-pages@v4 |
0 commit comments