|
| 1 | +name: test-for-building-website |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pages: write |
| 6 | + id-token: write |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: "pages" |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Install Hugo CLI |
| 24 | + # env: |
| 25 | + # HUGO_VERSION: 0.135.0 |
| 26 | + run: | |
| 27 | + if [ -z $HUGO_VERSION ]; then |
| 28 | + echo "[INFO] no HUGO_VERSION specified, use latest"; |
| 29 | + HUGO_VERSION=`curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | jq -r .tag_name | sed 's/^.//'`; |
| 30 | + fi |
| 31 | + echo "[INFO] Hugo version: ${HUGO_VERSION}" |
| 32 | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb |
| 33 | + sudo dpkg -i ${{ runner.temp }}/hugo.deb |
| 34 | + # - name: Install Dart Sass |
| 35 | + # run: sudo snap install dart-sass |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + submodules: recursive |
| 40 | + - name: Setup Pages |
| 41 | + id: pages |
| 42 | + uses: actions/configure-pages@v5 |
| 43 | + - name: Install Node.js dependencies |
| 44 | + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" |
| 45 | + - name: Build with Hugo |
| 46 | + env: |
| 47 | + HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache |
| 48 | + HUGO_ENVIRONMENT: production |
| 49 | + run: | |
| 50 | + hugo \ |
| 51 | + --minify \ |
| 52 | + --baseURL "${{ steps.pages.outputs.base_url }}/" |
| 53 | + - name: Upload artifact |
| 54 | + uses: actions/upload-pages-artifact@v3 |
| 55 | + with: |
| 56 | + path: ./public |
| 57 | + |
| 58 | + deploy: |
| 59 | + environment: |
| 60 | + name: github-pages |
| 61 | + url: ${{ steps.deployment.outputs.page_url }} |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: build |
| 64 | + steps: |
| 65 | + - name: Deploy to GitHub Pages |
| 66 | + id: deployment |
| 67 | + uses: actions/deploy-pages@v4 |
0 commit comments