-
Notifications
You must be signed in to change notification settings - Fork 9
107 lines (95 loc) · 3.1 KB
/
03-deploy-gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
name: Deploy to gh-pages
on:
workflow_call:
inputs:
release:
required: false
default: 'false'
type: string
preRelease:
required: false
default: 'false'
type: string
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: ⬇ Checkout repo
uses: actions/checkout@v4
- name: 🔄 Init Cache
uses: ./.github/actions/npm-cache
- name: ⬇ Download build
uses: actions/download-artifact@v4
with:
name: build
path: out
- name: ↔ Extract branch name
uses: ./.github/actions/extract-branch
id: extract_branch
- name: ↔ Extract branch/tag name
shell: bash
env:
RELEASE: ${{ inputs.release }}
PRE_RELEASE: ${{ inputs.preRelease }}
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch-name }}
run: |
if [[ $RELEASE == "true" || $PRE_RELEASE == "true" ]]
then
echo "name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "name=$BRANCH_NAME" >> $GITHUB_OUTPUT
fi
id: extract
- name: 📛 Get repo name
uses: actions/github-script@v7
id: repo-name
with:
result-encoding: string
script: return context?.payload?.repository?.name
- name: 🎩 Get owner name
uses: actions/github-script@v7
id: owner-name
with:
result-encoding: string
script: return context?.payload?.repository?.owner?.login
- name: 🔨 Build page
env:
RELEASE: ${{ inputs.release }}
PRE_RELEASE: ${{ inputs.preRelease }}
NAME: ${{ steps.extract.outputs.name }}
REPO_NAME: ${{ steps.repo-name.outputs.result }}
OWNER_NAME: ${{ steps.owner-name.outputs.result }}
run: |
chmod +rx ./.github/scripts/build-gh-page.sh
./.github/scripts/build-gh-page.sh
- name: 🥅 Deploy to GH-Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
- name: 🖨️ Print gh-pages url
env:
RELEASE: ${{ inputs.release }}
PRE_RELEASE: ${{ inputs.preRelease }}
NAME: ${{ steps.extract.outputs.name }}
REPO_NAME: ${{ steps.repo-name.outputs.result }}
OWNER_NAME: ${{ steps.owner-name.outputs.result }}
run: |
if [[ $RELEASE == "true" ]];
then
export URL=https://$OWNER_NAME.github.io/$REPO_NAME
elif [[ $PRE_RELEASE == "true" ]];
then
export URL=https://$OWNER_NAME.github.io/$REPO_NAME/version/${NAME}
else
export URL=https://$OWNER_NAME.github.io/$REPO_NAME/review/${NAME}
fi
echo "URL: $URL"
echo "### GH-Pages URL :rocket: <br> <br> $URL" >> $GITHUB_STEP_SUMMARY
- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}