-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (154 loc) · 5.32 KB
/
render-task-definition.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
---
name: 'Render task definition'
on:
workflow_call:
inputs:
# custom options
ref:
description: 'The branch/sha/tag to render the task definition from'
type: string
default: ''
artifact-name:
description: 'The name of the artifact to upload'
type: string
default: task-definition
# render-jinjanator-template options
template:
description: 'The path to the template file to render'
type: string
required: true
data:
description: 'The path to the file with data to pass to the render'
type: string
required: false
default: ''
format:
description: 'The format the data file will be in'
type: string
required: false
default: ''
format-options:
description: |
The format options to pass to the render. Each option should be in
format OPTION=VALUE with one on each line.
Example:
format-options: |
FOO=bar
BAR=baz
type: string
required: false
default: ''
environment:
description: |
The environment variables to pass to the render. Each environment
variable should be in format VAR=VAL with one on each line.
Example:
environment: |
FOO=bar
BAR=baz
type: string
required: false
default: ''
undefined:
description: 'If true, undefined variables will be used in templates (no error will be raised)'
type: string
required: false
default: 'false'
output:
description: 'The name of the output file to write rendered contents to'
type: string
required: false
default: 'task-definition.yml' # Changed default
# setup-python options
python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset."
type: string
default: ''
python-version-file:
description: "File containing the Python version to use. Example: .python-version"
type: string
default: ''
python-cache:
description: "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry."
type: string
required: false
# python requirements options
requirements-file:
description: 'The requirements file to install dependencies from, if not set will assume that it should install . via pyproject.toml'
type: string
default: ''
working-directory:
description: 'The base directory where files will exist'
type: string
default: infra
# aws options
aws-region:
description: 'The aws region where resources live'
type: string
default: us-east-1
secrets:
aws-account-id:
description: 'The AWS account id that the ecr repository lives under'
required: true
ssh-private-key:
description: 'An SSH private key to install for private dependencies'
required: false
defaults:
run:
shell: bash
jobs:
render-task-definition:
name: 'Render task definition'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: 'Setup python'
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
python-version-file: ${{ inputs.working-directory }}/${{ inputs.python-version-file }}
cache: ${{ inputs.python-cache }}
- name: 'If ssh private key provided, setup ssh agent'
id: ssh
run: |
has_key='false'
[ -z "${{ secrets.ssh-private-key }}" ] || has_key='true'
echo "has_key=$has_key" >> "$GITHUB_OUTPUT"
# for private dependencies
- name: 'Install SSH Key'
if: steps.ssh.outputs.has_key == 'true'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.ssh-private-key }}
- name: 'Install python dependencies'
working-directory: ${{ inputs.working-directory }}
run: |
if [ -n "${{ inputs.requirements-file }}" ]; then
pip install -r "${{ inputs.requirements-file }}"
elif [ -f pyproject.toml ]; then
pip install .
fi
- name: 'Render task definition'
id: render
uses: shopsmart/github-actions/actions/render-jinjanator-template@v4
with:
working-directory: ${{ inputs.working-directory }}
template: ${{ inputs.template }}
data: ${{ inputs.data }}
format: ${{ inputs.format }}
format-options: ${{ inputs.format-options }}
environment: |
TAG=${{ inputs.ref }}
AWS_ACCOUNT_ID=${{ secrets.aws-account-id }}
AWS_REGION=${{ inputs.aws-region }}
${{ inputs.environment }}
undefined: ${{ inputs.undefined }}
output: ${{ inputs.output }}
- name: 'Upload task definition'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ steps.render.outputs.file }}