tools: do pages deployment via actions (#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.

Myles Borins committed Aug 2, 2022 at 17:13 UTC 7beca8b4187ee08720615c7347dcfe4ff0231018
1 file changed +28 -35
.github/workflows/publish.yml
+28 -35
@@ -1,27 +1,29 @@
1 name: Publish
2
3 +
4 on:
5 push:
5 - branches: [ main ]
6 + branches:
7 + - main
8 +
9 + # Allows you to run this workflow manually from the Actions tab
10 + workflow_dispatch:
11
12 +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13 permissions:
8 - contents: write
14 + contents: read
15 + pages: write
16 + id-token: write
17
18 jobs:
11 - build:
19 + build-and-upload:
20 runs-on: ubuntu-latest
21 steps:
22 # Check out the content (source branch)
23 - name: Check out source
24 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
27 - name: Use Node.js
28 uses: actions/setup-node@v3
29 with:
@@ -35,27 +37,18 @@ jobs:
37 env:
38 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
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