-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathaction.yml
177 lines (163 loc) · 6.87 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Deploy PR Preview
author: Ross Williams
description: >
Deploy a pull request preview to GitHub Pages, similar to Vercel and
Netlify.
branding:
icon: git-pull-request
color: yellow
inputs:
token:
description: >
The token to use for the deployment.
Default is GITHUB_TOKEN in the current repository.
If you need more permissions for things such as deploying to another
repository, you can add a Personal Access Token (PAT).
required: false
default: ${{ github.token }}
preview-branch:
description: Branch on which the previews will be deployed.
required: false
default: gh-pages
umbrella-dir:
description: Path to the directory containing all previews.
required: false
default: pr-preview
pages-base-url:
description: URL of the repo's GitHub Pages site.
required: false
default: ""
pages-base-path:
description: Path that GitHub Pages is served from.
required: false
default: ""
source-dir:
description: Directory containing files to deploy.
required: false
default: .
deploy-repository:
description: >
The GitHub repository to deploy the preview to.
This should be formatted like `<org name>/<repo name>`, e.g.
`rossjrw/pr-preview-action`.
Defaults to the current repository.
You will need to add a Personal Access Token (PAT) in the `token` input
in order to allow the action running in one repository to make changes
to another repository.
required: false
default: ${{ github.repository }}
comment:
description: Whether to leave a sticky comment on the calling PR.
required: false
default: "true"
custom-url:
description: Deprecated, use `pages-base-url` instead.
deprecationMessage: Use `pages-base-url` instead.
required: false
default: ""
action:
description: >
Determines what this action will do when it is executed. Supported
values: `deploy`, `remove`, `auto` (default).
If set to `deploy`, will attempt to deploy the preview and overwrite
any existing preview in that location.
If set to `remove`, will attempt to remove the preview in that
location.
If set to `auto`, the action will try to determine whether to deploy
or remove the preview. It will deploy the preview on
`pull_request.types.synchronize` and `.opened` events, and remove it
on `pull_request.types.closed` events. It will not do anything for
all other events. `auto` is the default value.
required: false
default: auto
outputs:
deployment-action:
description: Resolved value of the 'action' input parameter (deploy, remove, none).
value: ${{ steps.setup.outputs.deployment_action }}
pages-base-url:
description: What this Action thinks the base URL of the GitHub Pages site is.
value: ${{ steps.setup.outputs.pages_base_url }}
preview-url-path:
description: Path to the preview from the Pages base URL.
value: ${{ steps.setup.outputs.preview_url_path }}
preview-url:
description: Full URL to the preview (https://[pages-base-url]/[preview-url-path]/).
value: ${{ steps.setup.outputs.preview_url }}
action-version:
description: The version of this Action when it was run.
value: ${{ steps.setup.outputs.action_version }}
action-start-timestamp:
description: The Unix timestamp that the action started.
value: ${{ steps.setup.outputs.action_start_timestamp }}
action-start-time:
description: The time that the action started in a readable format (UTC, depending on runner).
value: ${{ steps.setup.outputs.action_start_time }}
deployment-url:
description: Deprecated, use `preview-url` instead.
value: ${{ steps.setup.outputs.preview_url }}
runs:
using: composite
steps:
- name: Setup preview environment
id: setup
env:
deployment_action: ${{ inputs.action }}
umbrella_path: ${{ inputs.umbrella-dir }}
pages_base_url: ${{ inputs.pages-base-url }}
pages_base_path: ${{ inputs.pages-base-path }}
pr_number: ${{ github.event.number }}
github_action_ref: ${{ github.action_ref }}
github_action_repository: ${{ github.action_repository }}
deployment_repository: ${{ inputs.deploy-repository }}
token: ${{ inputs.token }}
deprecated_custom_url: ${{ inputs.custom-url }}
run: $GITHUB_ACTION_PATH/lib/main.sh
shell: bash
- name: Deploy preview directory
if: env.deployment_action == 'deploy'
uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0
with:
token: ${{ inputs.token }}
repository-name: ${{ inputs.deploy-repository }}
branch: ${{ inputs.preview-branch }}
folder: ${{ inputs.source-dir }}
target-folder: ${{ env.preview_file_path }}
commit-message: Deploy preview for PR ${{ github.event.number }} 🛫
force: false
- name: Leave a comment after deployment
if: |
env.deployment_action == 'deploy' &&
env.deployment_status == 'success' &&
(inputs.comment == 'true' || inputs.comment == true)
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-preview
message: |
[PR Preview Action](https://github.com/${{ env.action_repository }}) ${{ env.action_version }}
:---:
| <p></p> :rocket: View preview at <br> ${{ env.preview_url }} <br><br>
| <h6>Built to branch [`${{ inputs.preview-branch }}`](${{ github.server_url }}/${{ inputs.deploy-repository }}/tree/${{ inputs.preview-branch }}) at ${{ env.action_start_time }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ inputs.deploy-repository }}/deployments) is complete. <br><br> </h6>
- name: Remove preview directory
if: env.deployment_action == 'remove'
uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0
with:
token: ${{ inputs.token }}
repository-name: ${{ inputs.deploy-repository }}
branch: ${{ inputs.preview-branch }}
folder: ${{ env.empty_dir_path }}
target-folder: ${{ env.preview_file_path }}
commit-message: Remove preview for PR ${{ github.event.number }} 🛬
force: false
- name: Leave a comment after removal
if: |
env.deployment_action == 'remove' &&
env.deployment_status == 'success' &&
(inputs.comment == 'true' || inputs.comment == true)
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-preview
message: |
[PR Preview Action](https://github.com/${{ env.action_repository }}) ${{ env.action_version }}
:---:
Preview removed because the pull request was closed.
${{ env.action_start_time }}