-
Notifications
You must be signed in to change notification settings - Fork 8
/
action.yml
173 lines (164 loc) · 6.22 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
name: 'Setup LocalStack'
description: 'Sets up LocalStack CLI in your GitHub Actions workflow.'
author: 'LocalStack Team'
branding:
icon: 'code'
color: 'white'
inputs:
image-tag:
description: 'Tag of the LocalStack Docker image to use'
required: true
default: 'latest'
install-awslocal:
description: 'Whether to install the `awslocal` CLI into the environment'
required: true
default: 'true'
use-pro:
description: 'Whether to use LocalStack Pro (requires a valid API key)'
required: false
default: 'false'
configuration:
description: 'Configuration variables to use for LocalStack'
required: false
default: ''
ci-project:
description: 'Name of the CI project to track in LocalStack Cloud'
required: false
default: ''
github-token:
description: 'Github token used to create PR comments'
required: false
default: ''
preview-cmd:
description: 'Command(s) used to create an Ephemeral Instance of the PR (can use $AWS_ENDPOINT_URL)'
required: false
include-preview:
description: 'Whether to include the created Ephemeral Instance URL in the PR comment'
required: false
skip-startup:
description: |
Explicitly prevent LocalStack start up, only installs CLI(s).
Recommended to manage state later on in the pipeline or start up an ephemeral instance
required: true
default: 'false'
skip-wait:
description: 'Skip wait for LocalStack'
required: false
default: 'false'
skip-ephemeral-stop:
description: 'Skip stopping LocalStack Ephemeral Instance'
required: false
default: 'true'
state-action:
description: |
Manage LocalStack state
Valid values are `load`, `save`, `start`, `stop`, `` (empty, don't manage state)
Values `start`/`stop` only usable with Ephemeral Instances.
required: false
default: ''
state-backend:
description: |
Either store the state of LocalStack locally, as a cloud pod or start up an ephemeral instance.
Valid values are `cloud-pods`, `ephemeral` or `local`.
Use this option in unison with `state-action` to control behaviour.
required: false
default: 'cloud-pods'
state-name:
description: 'Name of the state artifact (without extension)'
required: false
auto-load-pod:
description: 'The pod to load on startup of LocalStack, the env var AUTO_LOAD_POD'
required: false
default: ''
extension-auto-install:
description: 'The extension(s) to automatically install on startup of LocalStack, the env var EXTENSION_AUTO_INSTALL'
required: false
default: ''
lifetime:
description: 'The lifetime of the ephemeral instance, how long the instance should be available for'
required: false
default: '30'
runs:
using: "composite"
steps:
- run: >
echo "GH_ACTION_ROOT=$(
ls -d $(
ls -d ./../../_actions/* |
grep -i localstack |
tail -n1
)/setup-localstack/* |
grep -v completed |
tail -n1
)" >> $GITHUB_ENV
shell: bash
- name: Install tools
uses: jenseng/dynamic-uses@v1
if: ${{ inputs.skip-startup == 'true' || inputs.state-backend == 'ephemeral' || inputs.state-action == 'save' }}
with:
uses: ${{ env.GH_ACTION_ROOT }}/tools
with: |-
{
"install-awslocal": ${{ toJSON(inputs.install-awslocal) }},
}
- name: Start Localstack
uses: jenseng/dynamic-uses@v1
if: ${{ inputs.skip-startup != 'true' && inputs.state-backend != 'ephemeral' && inputs.state-action != 'save' }}
with:
# now we can dynamically determine sub-action path 🥳
uses: ${{ env.GH_ACTION_ROOT }}/startup
# the `with` needs to be converted to a valid json string
# keeping in there install-awslocal for backward compatibility
with: |-
{
"image-tag": ${{ toJSON(inputs.image-tag) }},
"install-awslocal": ${{ toJSON(inputs.install-awslocal) }},
"use-pro": ${{ toJSON(inputs.use-pro) }},
"configuration": ${{ toJSON(inputs.configuration) }},
"ci-project": ${{ toJSON(inputs.ci-project) }},
"skip-wait": ${{ toJSON(inputs.skip-wait) }}
}
- name: Create Ephemeral Instance
if: ${{ inputs.state-action == 'start' && inputs.state-backend == 'ephemeral' }}
uses: jenseng/dynamic-uses@v1
with:
uses: ${{ env.GH_ACTION_ROOT }}/ephemeral/startup
with: |-
{
"github-token": ${{ toJSON(inputs.github-token) }},
"preview-cmd": ${{ toJSON(inputs.preview-cmd) }},
"extension-auto-install": ${{ toJSON(inputs.extension-auto-install )}},
"auto-load-pod": ${{ toJSON(inputs.auto-load-pod) }},
"lifetime": ${{ toJSON(inputs.lifetime )}}
}
# Use different artifact from current workflow's by passing the workflow's id as WORKFLOW_ID env variable
- name: Manage state
if: ${{ inputs.state-action == 'save' || inputs.state-action == 'load' }}
uses: jenseng/dynamic-uses@v1
with:
uses: ${{ env.GH_ACTION_ROOT }}/${{ inputs.state-backend }}
with: |-
{
"name": ${{ toJSON(inputs.state-name) }},
"action": ${{ toJSON(inputs.state-action) }}
}
- name: Display Ephemeral Instance URL
if: ${{ inputs.state-action == 'start' && inputs.state-backend == 'ephemeral' && (inputs.include-preview == 'true' || inputs.ci-project != '') }}
uses: jenseng/dynamic-uses@v1
with:
uses: ${{ env.GH_ACTION_ROOT }}/finish
with: |-
{
"github-token": ${{ toJSON(inputs.github-token) }},
"ci-project": ${{ toJSON(inputs.ci-project) }},
"include-preview": ${{ inputs.include-preview != '' && toJSON(inputs.include-preview) || toJSON(env.include-preview) }}
}
- name: Stop Ephemeral Instance
if: ${{ (inputs.skip-ephemeral-stop == 'false' || inputs.state-action == 'stop') && inputs.state-backend == 'ephemeral' }}
uses: jenseng/dynamic-uses@v1
with:
uses: ${{ env.GH_ACTION_ROOT }}/ephemeral/shutdown
with: |-
{
"github-token": ${{ toJSON(inputs.github-token) }},
}