Skip to content

Commit 8c4ff1c

Browse files
committed
ci: deploy fails because of missing public/ dir
Problem: Since moving to `peaceiris/actions-gh-pages` #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.
1 parent e0d2cf4 commit 8c4ff1c

File tree

3 files changed

+58
-38
lines changed

3 files changed

+58
-38
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Build Hugo Site"
2+
description: "Shared Hugo build logic"
3+
4+
env:
5+
HUGO_VERSION: "0.152.2"
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Install Hugo CLI
11+
run: |
12+
wget -O ${{ runner.temp }}/hugo.deb \
13+
https://github.com/gohugoio/hugo/releases/download/v${{ env.HUGO_VERSION }}/hugo_extended_${{ env.HUGO_VERSION }}_linux-amd64.deb \
14+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
15+
- name: Build with Hugo
16+
env:
17+
# For backward compatibility with Hugo modules
18+
HUGO_ENVIRONMENT: production
19+
HUGO_ENV: production
20+
run: |
21+
hugo --gc --minify --baseURL "$BASE_URL"
22+

.github/workflows/build.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Builds but does not deploy, for pull request validation.
2+
3+
name: build
4+
5+
on:
6+
# Runs on pull requests
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v6
15+
with:
16+
submodules: recursive
17+
fetch-depth: 0
18+
- name: Build site
19+
uses: ./.github/actions/build-site
20+
env:
21+
BASE_URL: "https://example.com/"
Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Builds and deploys the site to GitHub Pages.
2+
# Does NOT run on pull requests.
3+
14
name: build-and-deploy
25

36
on:
@@ -6,9 +9,6 @@ on:
69
branches:
710
- master
811

9-
# Runs on pull requests
10-
pull_request:
11-
1212
# Allows you to run this workflow manually from the Actions tab
1313
workflow_dispatch:
1414

@@ -30,50 +30,27 @@ defaults:
3030
shell: bash
3131

3232
jobs:
33-
# Build job
34-
build:
33+
# Deployment job
34+
build-and-deploy:
3535
runs-on: ubuntu-latest
36-
env:
37-
HUGO_VERSION: 0.152.2
36+
permissions:
37+
contents: write
38+
environment:
39+
name: github-pages
40+
url: ${{ steps.deployment.outputs.page_url }}
3841
steps:
39-
- name: Install Hugo CLI
40-
run: |
41-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
42-
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
4342
- name: Checkout
4443
uses: actions/checkout@v6
4544
with:
4645
submodules: recursive
4746
fetch-depth: 0
48-
- name: Build with Hugo
47+
- name: Build site
48+
uses: ./.github/actions/build-site
4949
env:
50-
# For maximum backward compatibility with Hugo modules
51-
HUGO_ENVIRONMENT: production
52-
HUGO_ENV: production
53-
run: |
54-
hugo \
55-
--gc \
56-
--minify \
57-
--baseURL "${{ steps.pages.outputs.base_url }}/"
58-
- name: Upload artifact
59-
uses: actions/upload-pages-artifact@v4
60-
with:
61-
path: ./public
62-
63-
# Deployment job
64-
deploy:
65-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
66-
environment:
67-
name: github-pages
68-
url: ${{ steps.deployment.outputs.page_url }}
69-
runs-on: ubuntu-latest
70-
permissions:
71-
contents: write
72-
needs: build
73-
steps:
74-
- name: Deploy to GitHub Pages
50+
BASE_URL: "${{ steps.pages.outputs.base_url }}/"
51+
- name: Deploy
7552
id: deployment
7653
uses: peaceiris/actions-gh-pages@v4
7754
with:
78-
github_token: ${{ secrets.GITHUB_TOKEN }}
7955
publish_dir: ./public
56+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)