|
1 |
| -# Sample workflow for building and deploying a Hugo site to GitHub Pages |
2 | 1 | name: Deploy Hugo site to Pages
|
3 | 2 |
|
4 | 3 | on:
|
5 |
| - # Runs on pushes targeting the default branch |
6 | 4 | push:
|
7 | 5 | branches: ["main"]
|
8 | 6 |
|
9 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
10 | 7 | permissions:
|
11 | 8 | contents: read
|
12 | 9 | pages: write
|
13 | 10 | id-token: write
|
14 | 11 |
|
15 |
| -# Environment variables available to all jobs and steps in this workflow |
16 | 12 | env:
|
17 | 13 | HUGO_ENV: production
|
18 | 14 | HUGO_VERSION: "0.118.2"
|
19 | 15 | GO_VERSION: "1.20.5"
|
20 | 16 | NODE_VERSION: "18.15.0"
|
21 |
| - TINA_CLIENT_ID: ${{ vars.TINA_CLIENT_ID }} |
22 |
| - TINA_TOKEN: ${{ vars.TINA_TOKEN }} |
23 | 17 |
|
24 | 18 | jobs:
|
25 |
| - # Build job |
26 | 19 | build:
|
27 |
| - runs-on: ubuntu-latest |
| 20 | + runs-on: ubuntu-24.04-arm |
28 | 21 | steps:
|
29 |
| - - uses: actions/checkout@v3 |
30 |
| - - name: Set up Node.js |
31 |
| - uses: actions/setup-node@v3 |
32 |
| - with: |
33 |
| - node-version: ${{ env.NODE_VERSION }} |
34 |
| - |
35 | 22 | - name: Install Hugo
|
36 | 23 | run: |
|
37 |
| - curl -LO "https://github.com/gohugoio/hugo/releases/download/v${{ env.HUGO_VERSION }}/hugo_extended_${{ env.HUGO_VERSION }}_Linux-64bit.tar.gz" |
38 |
| - tar -xvf hugo_extended_${{ env.HUGO_VERSION }}_Linux-64bit.tar.gz |
39 |
| - sudo mv hugo /usr/local/bin/ |
40 |
| - rm hugo_extended_${{ env.HUGO_VERSION }}_Linux-64bit.tar.gz |
41 |
| - hugo version |
| 24 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.deb \ |
| 25 | + && sudo dpkg -i ${{ runner.temp }}/hugo.deb |
42 | 26 |
|
43 | 27 | - name: Install Go
|
44 | 28 | run: |
|
45 |
| - curl -LO "https://dl.google.com/go/go${{ env.GO_VERSION }}.linux-amd64.tar.gz" |
46 |
| - sudo tar -C /usr/local -xzf go${{ env.GO_VERSION }}.linux-amd64.tar.gz |
47 |
| - echo "export PATH=$PATH:/usr/local/go/bin" >> $GITHUB_ENV |
48 |
| - rm go${{ env.GO_VERSION }}.linux-amd64.tar.gz |
49 |
| - go version |
| 29 | + wget -O ${{ runner.temp }}/go.deb https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz \ |
| 30 | + && sudo tar -C /usr/local -xzf ${{ runner.temp }}/go.deb |
| 31 | +
|
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4.2.2 |
| 34 | + with: |
| 35 | + submodules: recursive |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Setup Pages |
| 39 | + id: pages |
| 40 | + uses: actions/configure-pages@v5 |
50 | 41 |
|
51 | 42 | - name: Setup Project
|
52 | 43 | run: npm run project-setup
|
53 | 44 |
|
54 | 45 | - name: Install npm dependencies
|
55 | 46 | run: npm install
|
56 | 47 |
|
57 |
| - - name: Publish to GitHub Pages |
| 48 | + - name: Determine Base URL |
| 49 | + id: base_url |
| 50 | + run: | |
| 51 | + REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2) |
| 52 | + if [[ "${{ github.repository_owner }}" == "${{ github.repository_owner }}" ]]; then |
| 53 | + BASE_URL="https://${{ github.repository_owner }}.github.io/${REPO_NAME}/" |
| 54 | + else |
| 55 | + BASE_URL="https://${{ github.repository_owner }}.github.io/" |
| 56 | + fi |
| 57 | + echo "BASE_URL=$BASE_URL" >> $GITHUB_ENV |
| 58 | +
|
| 59 | + - name: Modify hugo.toml |
| 60 | + run: sed -i "s|baseURL = .*|baseURL = \"$BASE_URL\"|" hugo.toml |
| 61 | + |
| 62 | + - name: Build site |
58 | 63 | run: npm run build
|
59 | 64 |
|
60 | 65 | - name: Upload artifact
|
61 |
| - uses: actions/upload-pages-artifact@v3 |
| 66 | + uses: actions/upload-pages-artifact@v3.0.1 |
62 | 67 | with:
|
63 | 68 | path: ./public
|
64 | 69 |
|
65 |
| - # Deployment job |
66 | 70 | deploy:
|
67 | 71 | environment:
|
68 | 72 | name: github-pages
|
69 | 73 | url: ${{ steps.deployment.outputs.page_url }}
|
70 |
| - runs-on: ubuntu-latest |
| 74 | + runs-on: ubuntu-24.04-arm |
71 | 75 | needs: build
|
72 | 76 | steps:
|
73 | 77 | - name: Deploy to GitHub Pages
|
74 | 78 | id: deployment
|
75 |
| - uses: actions/deploy-pages@v2 |
| 79 | + uses: actions/deploy-pages@v4.0.5 |
0 commit comments