|
1 |
| -name: Deployment to GitHub Pages |
| 1 | +# Sample workflow for building and deploying a Hugo site to GitHub Pages |
| 2 | +name: Deploy Hugo site to Pages |
2 | 3 |
|
3 | 4 | on:
|
4 |
| - workflow_dispatch: |
| 5 | + # Runs on pushes targeting the default branch |
5 | 6 | push:
|
6 | 7 | branches:
|
7 |
| - - main # <-- specify the branch you want to deploy from |
8 |
| - pull_request: |
| 8 | + - main |
9 | 9 |
|
10 |
| -env: |
11 |
| - REPO_NAME: ${{ github.event.repository.name }} |
12 |
| - REPO_OWNER: ${{ github.repository_owner }} |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
13 | 12 |
|
14 |
| -jobs: |
15 |
| - deploy: |
16 |
| - runs-on: ubuntu-latest |
17 |
| - concurrency: |
18 |
| - group: ${{ github.workflow }}-${{ github.ref }} |
19 |
| - steps: |
20 |
| - - uses: actions/checkout@v4 |
21 |
| - with: |
22 |
| - fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod |
| 13 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pages: write |
| 17 | + id-token: write |
23 | 18 |
|
24 |
| - - name: Setup Hugo |
25 |
| - uses: peaceiris/actions-hugo@v3 |
26 |
| - with: |
27 |
| - hugo-version: '0.129.0' |
28 |
| - extended: true |
| 19 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 20 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 21 | +concurrency: |
| 22 | + group: "pages" |
| 23 | + cancel-in-progress: false |
29 | 24 |
|
30 |
| - - name: Setup Go |
31 |
| - uses: actions/setup-go@v2 |
32 |
| - with: |
33 |
| - go-version: '1.22.1' |
| 25 | +# Default to bash |
| 26 | +defaults: |
| 27 | + run: |
| 28 | + shell: bash |
34 | 29 |
|
| 30 | +jobs: |
| 31 | + # Build job |
| 32 | + build: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + env: |
| 35 | + HUGO_VERSION: 0.134.2 |
| 36 | + steps: |
| 37 | + - name: Install Hugo CLI |
| 38 | + run: | |
| 39 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ |
| 40 | + && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
35 | 41 | - name: Install Dart Sass
|
36 | 42 | run: sudo snap install dart-sass
|
37 |
| - |
38 |
| - - name: Setup Node |
39 |
| - uses: actions/setup-node@v4 |
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@v4 |
40 | 45 | with:
|
41 |
| - node-version: '16' |
42 |
| - |
43 |
| - - name: Cache dependencies |
44 |
| - uses: actions/cache@v3 |
45 |
| - with: |
46 |
| - path: ~/.npm |
47 |
| - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
48 |
| - restore-keys: | |
49 |
| - ${{ runner.os }}-node- |
50 |
| - # - run: npm ci |
51 |
| - |
52 |
| - - name: Build |
| 46 | + submodules: recursive |
| 47 | + fetch-depth: 0 |
| 48 | + - name: Setup Pages |
| 49 | + id: pages |
| 50 | + uses: actions/configure-pages@v5 |
| 51 | + - name: Install Node.js dependencies |
| 52 | + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 53 | + - name: Build with Hugo |
| 54 | + env: |
| 55 | + HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache |
| 56 | + HUGO_ENVIRONMENT: production |
| 57 | + TZ: America/Los_Angeles |
53 | 58 | run: |
|
54 |
| - npm install -D --save autoprefixer |
55 |
| - npm install -D --save postcss-cli |
56 |
| - npm install -D --save postcss |
57 |
| - hugo |
58 |
| -
|
59 |
| - - name: Deploy |
60 |
| - uses: peaceiris/actions-gh-pages@v3 |
| 59 | + hugo \ |
| 60 | + --gc \ |
| 61 | + --minify \ |
| 62 | + --baseURL "${{ steps.pages.outputs.base_url }}/" |
| 63 | + - name: Upload artifact |
| 64 | + uses: actions/upload-pages-artifact@v3 |
61 | 65 | with:
|
62 |
| - #deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} |
63 |
| - github_token: ${{ secrets.GITHUB_TOKEN }} |
64 |
| - publish_dir: ./public |
| 66 | + path: ./public |
| 67 | + |
| 68 | + # Deployment job |
| 69 | + deploy: |
| 70 | + environment: |
| 71 | + name: github-pages |
| 72 | + url: ${{ steps.deployment.outputs.page_url }} |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: build |
| 75 | + steps: |
| 76 | + - name: Deploy to GitHub Pages |
| 77 | + id: deployment |
| 78 | + uses: actions/deploy-pages@v4 |
0 commit comments