Skip to content

Commit a55e30e

Browse files
ci: deploy to github pages using specialize action (#308)
1 parent 945dbce commit a55e30e

File tree

2 files changed

+8
-31
lines changed

2 files changed

+8
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
- name: Upload demo-dist folder
172172
uses: actions/upload-artifact@v3
173173
with:
174-
name: demo-dist
174+
name: github-pages
175175
path: ./demo-dist
176176

177177
buildRelease:

.github/workflows/push.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,17 @@ jobs:
99
uses: ./.github/workflows/ci.yml
1010

1111
deploy-to-gh-pages:
12-
name: Deploy to `npm` branch
12+
name: Deploy to GitHub Pages
1313
needs: ci
1414
if: github.ref == 'refs/heads/main'
1515
environment:
1616
name: github-pages
17-
url: ${{ github.server_url }}/${{ github.repository }}/tree/gh-pages
17+
url: ${{ steps.deployment.outputs.page_url }}
1818
runs-on: ubuntu-latest
1919
permissions:
20-
contents: read # for actions/checkout
20+
pages: write # for actions/deploy-pages
21+
id-token: write # for actions/deploy-pages
2122
steps:
22-
- name: Checkout `gh-pages` branch
23-
uses: actions/checkout@v3
24-
with:
25-
ref: gh-pages
26-
27-
- name: Remove existing files first
28-
run: git rm -r .
29-
30-
- uses: actions/download-artifact@v3
31-
with:
32-
name: demo-dist
33-
34-
- name: Publish target branch
35-
run: |
36-
git add -A
37-
if git diff --staged --quiet; then
38-
echo 'Nothing to publish'
39-
else
40-
git config user.name 'GitHub Action Script'
41-
git config user.email '[email protected]'
42-
43-
git commit -a -m "$COMMIT_MESSAGE"
44-
git push
45-
echo 'Pushed'
46-
fi
47-
env:
48-
COMMIT_MESSAGE: 'Deploy ${{github.event.workflow_run.head_sha}} to `gh_pages` branch'
23+
- name: Deploy to GitHub Pages
24+
id: deployment
25+
uses: actions/deploy-pages@v2

0 commit comments

Comments
 (0)