-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
130 lines (127 loc) · 4.28 KB
/
action.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: markbind-action
description: 'Deploy your MarkBind site'
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
token:
description: the required token
required: true
service:
description: the publishing service
default: 'gh-pages'
type: string
purpose:
description: the deployment purpose, could be standard deployment or for PR preview
default: 'deployment'
type: string
domain:
description: the domain to use
type: string
version:
description: the MarkBind version to use. e.g. 4.0.0
default: 'latest'
type: string
rootDirectory:
description: the directory to read source files from
default: '.'
type: string
baseUrl:
description: the base URL relative to your domain
default: 'unsetFlag' # a flag indicating that baseUrl defaults to the one specified in site.json config file
type: string
siteConfig:
description: the site config file to use
default: 'site.json'
type: string
keepFiles:
description: whether the existing files will be removed in the published branch, before pushing.
default: false
type: boolean
runs:
using: "composite"
steps:
- name: Checkout source repo
uses: actions/checkout@v3
with:
path: curr-repo
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Checkout markbind-cli@master
if: inputs.version == 'development'
uses: actions/checkout@v3
with:
repository: MarkBind/markbind
path: markbind-cli
- name: Install markbind-cli@master
if: inputs.version == 'development'
run: |
cd markbind-cli
npm run setup && npm run build:web
cd packages/cli
npm link
cd ../../..
shell: bash
- name: Install a released version of markbind-cli
if: inputs.version != 'development'
run: |
npm install -g markbind-cli@${{ inputs.version }}
shell: bash
- name: Build site
run: |
BASEURL="--baseUrl ${{ inputs.baseUrl }}"
if [[ "${{ inputs.baseUrl }}" == "unsetFlag" ]]; then
BASEURL=""
echo "Default baseUrl to the config file attribute"
fi
cd curr-repo
markbind build ${{ inputs.rootDirectory }} ./_site \
$BASEURL --site-config ${{ inputs.siteConfig }}
cd ..
echo "Site Built!"
shell: bash
- name: Deploy via gh-pages
if: inputs.service == 'gh-pages'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ inputs.token }}
publish_dir: ./curr-repo/_site
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
keep_files: ${{ inputs.keepFiles }}
- name: Deploy via Surge.sh for normal deployment
if: inputs.service == 'surge' && inputs.purpose == 'deployment'
run: |
npm i -g surge
surge --project ./curr-repo/_site --domain ${{ inputs.domain }}
shell: bash
env:
SURGE_TOKEN: ${{ inputs.token }}
- name: Deploy via Surge.sh for PR Preview
if: inputs.service == 'surge' && inputs.purpose == 'pr-preview' && github.event_name == 'pull_request'
run: |
echo "prNum=${{ github.event.number }}" >> $GITHUB_ENV
npm i -g surge
PR_PREVIEW_URL="https://pr-${{ github.event.number }}-${{ inputs.domain }}"
echo "previewUrl=$PR_PREVIEW_URL" >> $GITHUB_ENV
surge --project ./curr-repo/_site --domain $PR_PREVIEW_URL
shell: bash
env:
SURGE_TOKEN: ${{ inputs.token }}
- name: Find existing PR preview link comment
if: inputs.service == 'surge' && inputs.purpose == 'pr-preview' && github.event_name == 'pull_request'
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ env.prNum }}
body-includes: Your PR can be previewed
- name: Comment PR preview link in PR
if: inputs.service == 'surge' && inputs.purpose == 'pr-preview' && github.event_name == 'pull_request' && steps.fc.outputs.comment-id == 0
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ env.prNum }}
body: |
Thank you for submitting the Pull Request! :thumbsup:
Your PR can be previewed [here](${{ env.previewUrl }})