Skip to content

Commit 76f2894

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 76f2894

File tree

3 files changed

+59
-43
lines changed

3 files changed

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

.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 & 43 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

@@ -24,56 +24,28 @@ concurrency:
2424
group: "pages"
2525
cancel-in-progress: false
2626

27-
# Default to bash
28-
defaults:
29-
run:
30-
shell: bash
31-
3227
jobs:
33-
# Build job
34-
build:
28+
# Deployment job
29+
build-and-deploy:
3530
runs-on: ubuntu-latest
36-
env:
37-
HUGO_VERSION: 0.152.2
31+
permissions:
32+
contents: write
33+
environment:
34+
name: github-pages
35+
url: ${{ steps.deployment.outputs.page_url }}
3836
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
4337
- name: Checkout
4438
uses: actions/checkout@v6
4539
with:
4640
submodules: recursive
4741
fetch-depth: 0
48-
- name: Build with Hugo
42+
- name: Build site
43+
uses: ./.github/actions/build-site
4944
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
45+
BASE_URL: "${{ steps.pages.outputs.base_url }}/"
46+
- name: Deploy
7547
id: deployment
7648
uses: peaceiris/actions-gh-pages@v4
7749
with:
78-
github_token: ${{ secrets.GITHUB_TOKEN }}
7950
publish_dir: ./public
51+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)