-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
104 lines (99 loc) · 3.67 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
# Must only be ran from a successful workflow_run caused by a pull_request, if condition e.g.
# github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
name: Netlify PR Preview
description: Helper action to deploy PR previews to Netlify.
inputs:
path:
type: string
required: true
description: The path to the directory which should be deployed into Netlify
desc:
type: string
required: false
description: The description to set on the Github Deployment
default: |
Do you trust the author of this PR? Maybe this build will steal your keys or give you malware.
Exercise caution. Use test accounts.
prefix:
type: string
required: false
description: The prefix to use before the PR number in the Netlify subdomain
default: pr
deployment_env:
type: string
required: false
description: The Github environment with which to associate this deployment
default: Netlify
deployment_id:
type: string
required: false
description: The ID of an existing deployment to continue as part of this Netlify deployment, one will be created otherwise
# We cannot use ${{ github.repository_owner }} as in workflow runs from forks it'll be the upstream org
owner:
type: string
required: true
description: The owner (login) of the head repo of the PR
# We cannot use ${{ github.ref_name }} as in workflow runs it'll just be the default branch (develop)
branch:
type: string
required: true
description: The name of the head branch
# We cannot use ${{ github.sha }} here as for pull requests it'll be a simulated merge commit instead
revision:
type: string
required: true
description: The git revision with which this deployment should be associated
token:
type: string
required: true
description: The Netlify Auth Token
site_id:
type: string
required: true
description: The Netlify Site ID
runs:
using: composite
steps:
- name: 📝 Create Deployment
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1.5.0
if: inputs.deployment_id == ''
id: deployment
with:
step: start
token: ${{ github.token }}
env: ${{ inputs.deployment_env }}
ref: ${{ inputs.revision }}
desc: |
Do you trust the author of this PR? Maybe this build will steal your keys or give you malware.
Exercise caution. Use test accounts.
- id: prdetails
uses: matrix-org/[email protected]
continue-on-error: true
with:
owner: ${{ inputs.owner }}
branch: ${{ inputs.branch }}
- name: ☁️ Deploy to Netlify
id: netlify
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0.0
with:
publish-dir: ${{ inputs.path }}
deploy-message: "Deploy from GitHub Actions"
# These don't work because we're in workflow_run
enable-pull-request-comment: false
enable-commit-comment: false
alias: ${{ inputs.prefix }}${{ steps.prdetails.outputs.pr_id || inputs.branch }}
env:
NETLIFY_AUTH_TOKEN: ${{ inputs.token }}
NETLIFY_SITE_ID: ${{ inputs.site_id }}
- name: 🚦 Update deployment status
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1.5.0
if: always()
with:
step: finish
override: false
token: ${{ github.token }}
status: ${{ job.status }}
env: ${{ inputs.deployment_env }}
deployment_id: ${{ inputs.deployment_id || steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.netlify.outputs.deploy-url }}
desc: ${{ inputs.desc }}