Skip to content

Commit 0920fb1

Browse files
committed
Add a GitHub workflow to deploy gh-pages to GitHub Pages
When merging PRs, or pushing changes directly, we will want to deploy the result to GitHub Pages. That's this new workflow's job. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ec5b393 commit 0920fb1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

.github/actions/deploy-to-github-pages/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ outputs:
1616
runs:
1717
using: "composite"
1818
steps:
19-
- name: push changes
19+
- name: push changes (if needed)
2020
shell: bash
21-
run: git push origin HEAD
21+
run: |
22+
test "$(git rev-parse HEAD)" = "$(git rev-parse refs/remotes/origin/${{ github.ref_name }})" ||
23+
git push origin HEAD:${{ github.ref }}
2224
2325
- name: un-sparse worktree to prepare for deployment
2426
shell: bash

.github/workflows/deploy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- gh-pages
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pages: write # to deploy to GitHub Pages
14+
id-token: write # to verify that the deployment source is legit
15+
environment:
16+
name: github-pages
17+
url: ${{ steps.deploy.outputs.url }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: deploy to GitHub Pages
21+
id: deploy
22+
uses: ./.github/actions/deploy-to-github-pages

0 commit comments

Comments
 (0)