/ .github / workflows / deploy.yml
deploy.yml
 1  name: Build and Deploy
 2  
 3  on:
 4    push:
 5      branches: [master]
 6    workflow_dispatch:
 7  
 8  permissions:
 9    contents: read
10    pages: write
11    id-token: write
12  
13  concurrency:
14    group: pages
15    cancel-in-progress: true
16  
17  jobs:
18    build:
19      runs-on: ubuntu-latest
20      steps:
21        - uses: actions/checkout@v4
22  
23        - uses: ruby/setup-ruby@v1
24          with:
25            bundler-cache: true
26  
27        - name: Fetch guestbook data
28          run: python3 scripts/fetch-guestbook-data.py
29  
30        - name: Write build info
31          run: |
32            mkdir -p _data
33            echo "{\"commit\": \"${GITHUB_SHA:0:7}\", \"time\": \"$(date -u '+%Y-%m-%d %H:%M UTC')\"}" > _data/build.json
34  
35        - name: Build Jekyll
36          run: bundle exec jekyll build
37          env:
38            JEKYLL_ENV: production
39  
40        - name: Minify
41          run: |
42            go install github.com/tdewolff/minify/v2/cmd/minify@latest
43            $(go env GOPATH)/bin/minify -r -o _site/ _site/
44  
45        - uses: actions/configure-pages@v5
46  
47        - uses: actions/upload-pages-artifact@v3
48          with:
49            path: _site
50  
51    deploy:
52      needs: build
53      runs-on: ubuntu-latest
54      environment:
55        name: github-pages
56        url: ${{ steps.deployment.outputs.page_url }}
57      steps:
58        - id: deployment
59          uses: actions/deploy-pages@v4