From 63b2aa8af3473a71d0f9236aefd8b0f836d4830a Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Sun, 23 Oct 2022 15:52:18 +0100 Subject: [PATCH] Use Github Pages action --- .github/workflows/publish.yml | 75 +++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dc3dbceb..e24d3551 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,32 +1,63 @@ -name: CI +name: Deploy Hugo site to Pages + on: push: - branches: - - main + branches: ["main"] + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +defaults: + run: + shell: bash jobs: - deploy: + build: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }} + env: + HUGO_VERSION: 0.104.3 steps: - - name: Git checkout + - name: Install Hugo CLI + run: | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - name: Checkout uses: actions/checkout@v3 with: - fetch-depth: 0 - - - name: Setup hugo - uses: peaceiris/actions-hugo@v2 + submodules: recursive + - name: Setup Pages + id: pages + uses: actions/configure-pages@v2 + - name: Build with Hugo + env: + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo \ + --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 with: - hugo-version: '0.104.3' - extended: true + path: ./public - - name: Build - run: hugo --minify - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - personal_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public - cname: www.byjp.me + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1