|
1 |
| -name: Convert Markdown to HTML |
2 |
| -on: pull_request |
| 1 | +name: Hugo |
| 2 | +on: [pull_request] |
3 | 3 |
|
4 | 4 | jobs:
|
5 |
| - md2html: # make sure build/ci work properly |
| 5 | + build: |
6 | 6 | runs-on: ubuntu-latest
|
7 |
| - permissions: |
8 |
| - contents: write |
9 |
| - issues: write |
10 | 7 | steps:
|
11 |
| - - uses: actions/checkout@v4 |
12 |
| - with: |
13 |
| - repository: ${{ github.event.pull_request.head.repo.full_name }} |
14 |
| - ref: ${{ github.event.pull_request.head.ref }} |
15 |
| - - run: npm ci |
16 |
| - - run: npm run grunt |
17 |
| - - name: check if commit & push is needed |
18 |
| - id: check |
19 |
| - run: | |
20 |
| - git add -A \*.html && |
21 |
| - git diff-index --cached --exit-code HEAD -- || |
22 |
| - echo "need-to-commit=yes" >>$GITHUB_OUTPUT |
23 |
| - - name: commit |
24 |
| - if: steps.check.outputs.need-to-commit == 'yes' |
25 |
| - run: | |
26 |
| - git config user.name "${{github.actor}}" && |
27 |
| - git config user.email "${{github.actor}}@users.noreply.github.com" && |
28 |
| - git commit -m 'Convert Markdown to HTML' -- \*.html && |
29 |
| - git update-index --refresh && |
30 |
| - git diff-files --exit-code && |
31 |
| - git diff-index --cached --exit-code HEAD -- && |
32 |
| - git bundle create git.bundle ${{ github.event.pull_request.head.sha }}..${{ github.event.pull_request.head.ref }} |
33 |
| - - name: commit |
34 |
| - if: steps.check.outputs.need-to-commit == 'yes' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name |
35 |
| - run: git push |
36 |
| - - name: publish bundle |
37 |
| - id: bundle |
38 |
| - if: steps.check.outputs.need-to-commit == 'yes' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name |
39 |
| - uses: actions/upload-artifact@v4 |
40 |
| - with: |
41 |
| - name: bundle |
42 |
| - path: git.bundle |
43 |
| - - name: instructions how to fetch bundle |
44 |
| - if: steps.check.outputs.need-to-commit == 'yes' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name |
45 |
| - run: | |
46 |
| - body='The HTML pages are out of date. Please download the `bundle` artifact from ${{ steps.bundle.outputs.artifact-url }}, extract the `git.bundle` file from it, then run `git pull /path/to/git.bundle ${{ github.event.pull_request.head.ref }}` and then push to the PR branch' |
47 |
| - echo "::error::$body" >&2 |
48 |
| - echo "$body" >>$GITHUB_STEP_SUMMARY |
49 |
| - exit 1 |
| 8 | + - uses: actions/checkout@v4 |
| 9 | + - name: configure Hugo |
| 10 | + run: | |
| 11 | + set -x && |
| 12 | + echo "HUGO_VERSION=$(sed -n 's/^ *hugo_version: *//p' <hugo.yml)" >>$GITHUB_ENV |
| 13 | + - name: install Hugo ${{ env.HUGO_VERSION }} |
| 14 | + run: | |
| 15 | + set -x && |
| 16 | + curl -Lo /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v$HUGO_VERSION/hugo_extended_${HUGO_VERSION}_linux-amd64.deb && |
| 17 | + sudo dpkg -i /tmp/hugo.deb |
| 18 | + - name: run Hugo to build the pages |
| 19 | + run: hugo |
| 20 | + - name: build tar archive |
| 21 | + run: cd public && tar czvf ../pages.tar.gz * |
| 22 | + - name: Upload build artifact |
| 23 | + uses: actions/upload-artifact@v4 |
| 24 | + with: |
| 25 | + name: pages |
| 26 | + path: pages.tar.gz |
0 commit comments