From 76f28944f805e0c8dae8329b58705aef7a6b440f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 24 Nov 2025 19:25:23 -0500 Subject: [PATCH] ci: deploy fails because of missing public/ dir Problem: Since moving to `peaceiris/actions-gh-pages` https://github.com/neovim/neovim.github.io/pull/401 there is a new problem: /home/runner/actions_github_pages_1764026989086 cp: no such file or directory: /home/runner/work/neovim.github.io/neovim.github.io/public/* cp: no such file or directory: /home/runner/work/neovim.github.io/neovim.github.io/public/.* The old way magically worked because `actions/upload-pages-artifact` is internally handled by `actions/deploy-pages`. There is no complementary `actions/download-pages-artifact` so we have to do some other approach. Solution: Do the build in the deploy step, avoid uploading/downloading artifacts. --- .github/actions/build-site/action.yaml | 23 ++++++++ .github/workflows/build.yaml | 21 +++++++ .github/workflows/{hugo.yaml => deploy.yaml} | 58 +++++--------------- 3 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 .github/actions/build-site/action.yaml create mode 100644 .github/workflows/build.yaml rename .github/workflows/{hugo.yaml => deploy.yaml} (52%) diff --git a/.github/actions/build-site/action.yaml b/.github/actions/build-site/action.yaml new file mode 100644 index 0000000..4b2586c --- /dev/null +++ b/.github/actions/build-site/action.yaml @@ -0,0 +1,23 @@ +name: "Build Hugo Site" +description: "Shared Hugo build logic" + +runs: + using: "composite" + steps: + - name: Install Hugo CLI + shell: bash + env: + HUGO_VERSION: "0.152.2" + run: | + wget -O ${{ runner.temp }}/hugo.deb \ + https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - name: Build with Hugo + shell: bash + env: + # For backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo --gc --minify --baseURL "$BASE_URL" + diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..b5468f4 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,21 @@ +# Builds but does not deploy, for pull request validation. + +name: build + +on: + # Runs on pull requests + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: recursive + fetch-depth: 0 + - name: Build site + uses: ./.github/actions/build-site + env: + BASE_URL: "https://example.com/" diff --git a/.github/workflows/hugo.yaml b/.github/workflows/deploy.yaml similarity index 52% rename from .github/workflows/hugo.yaml rename to .github/workflows/deploy.yaml index e720053..495e99b 100644 --- a/.github/workflows/hugo.yaml +++ b/.github/workflows/deploy.yaml @@ -1,3 +1,6 @@ +# Builds and deploys the site to GitHub Pages. +# Does NOT run on pull requests. + name: build-and-deploy on: @@ -6,9 +9,6 @@ on: branches: - master - # Runs on pull requests - pull_request: - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -24,56 +24,28 @@ concurrency: group: "pages" cancel-in-progress: false -# Default to bash -defaults: - run: - shell: bash - jobs: - # Build job - build: + # Deployment job + build-and-deploy: runs-on: ubuntu-latest - env: - HUGO_VERSION: 0.152.2 + permissions: + contents: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} steps: - - 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-amd64.deb \ - && sudo dpkg -i ${{ runner.temp }}/hugo.deb - name: Checkout uses: actions/checkout@v6 with: submodules: recursive fetch-depth: 0 - - name: Build with Hugo + - name: Build site + uses: ./.github/actions/build-site env: - # For maximum backward compatibility with Hugo modules - HUGO_ENVIRONMENT: production - HUGO_ENV: production - run: | - hugo \ - --gc \ - --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" - - name: Upload artifact - uses: actions/upload-pages-artifact@v4 - with: - path: ./public - - # Deployment job - deploy: - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - permissions: - contents: write - needs: build - steps: - - name: Deploy to GitHub Pages + BASE_URL: "${{ steps.pages.outputs.base_url }}/" + - name: Deploy id: deployment uses: peaceiris/actions-gh-pages@v4 with: - github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public + github_token: ${{ secrets.GITHUB_TOKEN }}