Skip to content

Commit 7beca8b

Browse files
authored
tools: do pages deployment via actions (npm#160)
There is now support for deploying pages by actions bypassing the need to upload to a branch, this significantly simplifies the overall process and removed the need for a "dist" branch. I'm about 99% confident this will work out of the box, I've tested on two personal websites already.
1 parent d960b75 commit 7beca8b

File tree

1 file changed

+28
-35
lines changed

1 file changed

+28
-35
lines changed

.github/workflows/publish.yml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
name: Publish
22

3+
34
on:
45
push:
5-
branches: [ main ]
6+
branches:
7+
- main
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
611

12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
713
permissions:
8-
contents: write
14+
contents: read
15+
pages: write
16+
id-token: write
917

1018
jobs:
11-
build:
19+
build-and-upload:
1220
runs-on: ubuntu-latest
1321
steps:
1422
# Check out the content (source branch)
1523
- name: Check out source
1624
uses: actions/checkout@v3
17-
18-
# Check out the `dist` branch into the `public` directory.
19-
- name: Check out documentation branch
20-
uses: actions/checkout@v3
21-
with:
22-
ref: 'dist'
23-
path: 'public'
24-
25+
- name: Setup Pages
26+
uses: actions/configure-pages@v1
2527
- name: Use Node.js
2628
uses: actions/setup-node@v3
2729
with:
@@ -35,27 +37,18 @@ jobs:
3537
env:
3638
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3739

38-
# Check for changes; this avoids publishing a new change to the
39-
# dist branch when we made a change to (for example) a unit test.
40-
# If there were changes made in the publish step above, then this
41-
# will set the variable `has_changes` to `1` for subsequent steps.
42-
- name: Check for changes
43-
id: status
44-
run: |
45-
if [ -n "$(git status --porcelain)" ]; then
46-
echo "::set-output name=has_changes::1"
47-
fi
48-
working-directory: public
49-
50-
# Commit the changes to the dist branch and push the changes up to
51-
# GitHub. (Replace the name and email address with your own.)
52-
# This step only runs if the previous step set `has_changes` to `1`.
53-
- name: Publish documentation
54-
run: |
55-
git add --verbose .
56-
git config user.name 'npm CLI robot'
57-
git config user.email 'npm-cli+bot@github.com'
58-
git commit -m 'Update from CI'
59-
git push origin dist
60-
if: steps.status.outputs.has_changes == '1'
61-
working-directory: public
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v1
42+
with:
43+
path: './public'
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build-and-upload
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy