Skip to content

Commit fefb626

Browse files
Update main.yml
1 parent d870112 commit fefb626

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Main
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
publish_artifacts:
7+
description: "Publish artifacts (Y|N)"
8+
required: true
9+
default: "N"
510
release:
611
types: [published]
712
push:
@@ -50,3 +55,38 @@ jobs:
5055
with:
5156
name: site
5257
path: site.zip
58+
59+
publish:
60+
if: github.ref == 'refs/heads/main' || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_artifacts == 'Y')
61+
needs: build
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v1
67+
with:
68+
fetch-depth: 1
69+
70+
- name: Download artifact
71+
uses: actions/download-artifact@v3
72+
with:
73+
name: site
74+
path: site
75+
76+
- name: Unzip artifact
77+
run: |
78+
unzip site/site.zip -d site
79+
80+
- name: Deploy to gh-pages branch
81+
run: |
82+
git config user.name "${GITHUB_ACTOR}"
83+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
84+
git checkout --orphan gh-pages
85+
git reset --hard
86+
mv site/* .
87+
rm -rf site
88+
git clean -fdx
89+
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
90+
git add .
91+
git commit -m "Deploy documentation to gh-pages"
92+
git push --force $remote_repo gh-pages

0 commit comments

Comments
 (0)