Skip to content

Commit 3454ee7

Browse files
authored
feat: various changes for v0.4.0 (#4)
1 parent c96b9b8 commit 3454ee7

File tree

7 files changed

+175
-38
lines changed

7 files changed

+175
-38
lines changed

.github/workflows/build_docker_image_and_push_to_ecr.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,29 @@ on:
2727
default: us-east-1
2828
slackChannelId:
2929
description: Slack Channel ID
30-
required: true
30+
required: false
3131
type: string
3232
setNodeVersion:
33-
description: Put NODE_VERSION from .nvmrc to docker build args
33+
description: Put NODE_VERSION from path/to/.nvmrc to docker build args
3434
required: false
3535
type: string
3636
default: true
37+
nvmrcPath:
38+
description: Path to nvmrc file
39+
required: false
40+
type: string
41+
default: .nvmrc
3742
dockerBuildArgs:
3843
description: Values for --build-arg argument
3944
required: false
4045
type: string
4146
# This is just a dummy default, so docker does not complain
4247
default: FOO=BAR
48+
dockerContext:
49+
description: Relative path to git context
50+
required: false
51+
type: string
52+
default: '.'
4353
actorOverride:
4454
description: Override the author of event
4555
required: false
@@ -54,7 +64,7 @@ on:
5464
required: true
5565
slackToken:
5666
description: Slack API token
57-
required: true
67+
required: false
5868
npmToken:
5969
description: Put NPM_TOKEN to docker build args
6070
required: false
@@ -64,13 +74,12 @@ env:
6474
AWS_SECRET_ACCESS_KEY: ${{ secrets.awsSecretAccessKey }}
6575
AWS_REGION: ${{ inputs.awsRegion }}
6676

67-
# NPMRC_TEMP_FILE: npmrc-temp-file
68-
6977
jobs:
7078
build:
7179
runs-on: ubuntu-latest
7280
steps:
7381
- name: Send notification to slack
82+
if: inputs.slackChannelId != ''
7483
uses: slackapi/slack-github-action@v1.19.0
7584
env:
7685
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}
@@ -116,7 +125,7 @@ jobs:
116125
run: |
117126
BUILD_ARGS=${{ inputs.dockerBuildArgs }}
118127
if [ "${{ inputs.setNodeVersion }}" = true ]; then
119-
BUILD_ARGS="${BUILD_ARGS}\nNODE_VERSION=$(head -1 .nvmrc)"
128+
BUILD_ARGS="${BUILD_ARGS}\nNODE_VERSION=$(head -1 ${{ inputs.nvmrcPath }})"
120129
fi
121130
122131
echo 'BUILD_ARGS<<EOF' >> $GITHUB_ENV
@@ -141,6 +150,7 @@ jobs:
141150
id: build_and_push
142151
uses: docker/build-push-action@v3
143152
with:
153+
context: ${{ inputs.dockerContext }}
144154
file: ${{ inputs.dockerFilePath }}
145155
push: true
146156
tags: ${{ inputs.registry }}/${{ inputs.repository }}:${{ inputs.imageTag }}
@@ -150,7 +160,7 @@ jobs:
150160
151161
- name: helper - get slack message attachment color
152162
id: helper
153-
if: ${{ always() }}
163+
if: always() && inputs.slackChannelId != ''
154164
run: |
155165
if [ "${{ job.status }}" = "success" ]
156166
then
@@ -162,7 +172,7 @@ jobs:
162172
fi
163173
164174
- name: send result to slack
165-
if: ${{ always() }}
175+
if: always() && inputs.slackChannelId != ''
166176
uses: slackapi/slack-github-action@v1.19.0
167177
env:
168178
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}

.github/workflows/create_changelog.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
changelogScopes:
7-
description: 'changelog scopes (i.e { "App": ["app", "application"] })'
7+
description: 'Changelog scopes (i.e { "App": ["app", "application"] })'
88
required: true
99
type: string
1010
slackChannelId:
@@ -41,7 +41,6 @@ jobs:
4141
id: release
4242
with:
4343
github-token: ${{ secrets.GITHUB_TOKEN }}
44-
# result-encoding: string
4544
script: |
4645
// TODO: maybe parametrize
4746
const releaseName = process.env.GITHUB_HEAD_REF.split('/')[1];

.github/workflows/deploy_cloudformation.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
default: 3600
2020
slackChannelId:
2121
description: Slack Channel ID
22-
required: true
22+
required: false
2323
type: string
2424
actorOverride:
2525
description: Override the author of event
@@ -33,6 +33,10 @@ on:
3333
description: Path to cloudformation template file
3434
required: true
3535
type: string
36+
revision:
37+
description: Revision of change
38+
required: true
39+
type: string
3640
s3Bucket:
3741
description: S3 bucket where templates will be stored
3842
required: false
@@ -59,13 +63,14 @@ on:
5963
required: true
6064
slackToken:
6165
description: Slack API token
62-
required: true
66+
required: false
6367

6468
jobs:
6569
deploy:
6670
runs-on: ubuntu-latest
6771
steps:
6872
- name: send notification to slack
73+
if: inputs.slackChannelId != ''
6974
uses: slackapi/slack-github-action@v1.19.0
7075
env:
7176
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}
@@ -87,7 +92,7 @@ jobs:
8792
},
8893
{
8994
"type": "mrkdwn",
90-
"text": "*Revision:* ${{ inputs.imageTag }}"
95+
"text": "*Revision:* ${{ inputs.revision }}"
9196
},
9297
{
9398
"type": "mrkdwn",
@@ -116,13 +121,25 @@ jobs:
116121
role-to-assume: ${{ inputs.awsRoleArn }}
117122
role-duration-seconds: ${{ inputs.awsSessionDuration }}
118123

124+
# This parameter is needed otherwise this action is trying to tag session
125+
# which does not work for cross-account assume
126+
role-skip-session-tagging: true
127+
119128
# Since the official cloudformation deploy action is archived for some reason, let's script this!
120129
- name: deploy
121130
run: |
122-
OPTIONAL_PARAMETERS=""
131+
OUTPUT_TEMPLATE_FILE=${{ inputs.templateFile }}
123132
if [ "${{ inputs.s3Bucket }}" != "" ]; then
124-
OPTIONAL_PARAMETERS="${OPTIONAL_PARAMETERS} --s3-bucket ${{ inputs.s3Bucket }}"
133+
echo ">>> Checking of bucket exists. If not, will try to create it"
134+
aws s3 ls | grep ${{ inputs.s3Bucket }} > /dev/null || aws s3 mb s3://${{ inputs.s3Bucket }} > /dev/null
135+
OUTPUT_TEMPLATE_FILE=$(dirname ${{ inputs.templateFile }})/pkg_$(basename ${{ inputs.templateFile }})
136+
aws cloudformation package \
137+
--template-file ${{ inputs.templateFile }} \
138+
--s3-bucket ${{ inputs.s3Bucket }} \
139+
--output-template-file ${OUTPUT_TEMPLATE_FILE}
125140
fi
141+
142+
OPTIONAL_PARAMETERS=""
126143
if [ "${{ inputs.parameters }}" != "" ]; then
127144
OPTIONAL_PARAMETERS="${OPTIONAL_PARAMETERS} --parameter-overrides ${{ inputs.parameters }}"
128145
fi
@@ -134,12 +151,12 @@ jobs:
134151
fi
135152
aws cloudformation deploy \
136153
--stack-name ${{ inputs.stackName }} \
137-
--template-file ${{ inputs.templateFile }} ${OPTIONAL_PARAMETERS}
138-
154+
--template-file ${OUTPUT_TEMPLATE_FILE} \
155+
--tags revision=${{ inputs.revision }} ${OPTIONAL_PARAMETERS}
139156
140157
- name: helper - get slack message formatting
141158
id: helper
142-
if: ${{ always() }}
159+
if: always() && inputs.slackChannelId != ''
143160
run: |
144161
if [ "${{ job.status }}" = "success" ]
145162
then
@@ -151,15 +168,15 @@ jobs:
151168
fi
152169
153170
- name: send result to slack
154-
if: ${{ always() }}
171+
if: always() && inputs.slackChannelId != ''
155172
uses: slackapi/slack-github-action@v1.19.0
156173
env:
157174
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}
158175
with:
159176
channel-id: ${{ inputs.slackChannelId }}
160177
payload: |
161178
{
162-
"text": ":${{ steps.helper.outputs.emoji }}: *${{ github.repository }} deploy result: ${{ job.status }}*",
179+
"text": ":${{ steps.helper.outputs.emoji }}: *${{ github.repository }} deploy of cloudformation stack ${{ inputs.stackName }} result: ${{ job.status }}*",
163180
"attachments": [
164181
{
165182
"color": "${{ steps.helper.outputs.color }}",
@@ -173,7 +190,7 @@ jobs:
173190
},
174191
{
175192
"type": "mrkdwn",
176-
"text": "*Revision:* ${{ inputs.imageTag }}"
193+
"text": "*Revision:* ${{ inputs.revision }}"
177194
},
178195
{
179196
"type": "mrkdwn",

.github/workflows/deploy_helmfile.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: deploy helmfile
33
on:
44
workflow_call:
55
inputs:
6-
imageTag:
6+
revision:
77
description: Tag given to container image
88
required: true
99
type: string
@@ -47,12 +47,17 @@ on:
4747
# BAR=foo
4848
slackChannelId:
4949
description: Slack Channel ID
50-
required: true
50+
required: false
5151
type: string
5252
actorOverride:
5353
description: Override the author of event
5454
required: false
5555
type: string
56+
helmfileCommand:
57+
description: Command run by helmfile
58+
required: false
59+
type: string
60+
default: sync
5661

5762
secrets:
5863
awsAccessKeyId:
@@ -63,7 +68,7 @@ on:
6368
required: true
6469
slackToken:
6570
description: Slack API token
66-
required: true
71+
required: false
6772

6873
env:
6974
AWS_ACCESS_KEY_ID: ${{ secrets.awsAccessKeyId }}
@@ -75,14 +80,15 @@ jobs:
7580
runs-on: ubuntu-latest
7681
steps:
7782
- name: Send notification to slack
83+
if: inputs.slackChannelId != ''
7884
uses: slackapi/slack-github-action@v1.19.0
7985
env:
8086
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}
8187
with:
8288
channel-id: ${{ inputs.slackChannelId }}
8389
payload: |
8490
{
85-
"text": ":large_blue_circle: *${{ github.repository }} deploy started*",
91+
"text": ":large_blue_circle: *${{ github.repository }} deploy of helmfile started*",
8692
"attachments": [
8793
{
8894
"color": "#0066ff",
@@ -96,7 +102,7 @@ jobs:
96102
},
97103
{
98104
"type": "mrkdwn",
99-
"text": "*Revision:* ${{ inputs.imageTag }}"
105+
"text": "*Revision:* ${{ inputs.revision }}"
100106
},
101107
{
102108
"type": "mrkdwn",
@@ -163,17 +169,17 @@ jobs:
163169
- name: setup kubeconfig
164170
run: aws eks update-kubeconfig --name ${{ inputs.eksClusterName }} $OPTIONAL_PARAMS
165171

166-
- name: helmfile sync
172+
- name: helmfile ${{ inputs.helmfileCommand }}
167173
run: |
168174
export $(echo ${{ inputs.envVariables }})
169175
HELMFILE_PARAMS="-f ${{ inputs.helmfilePath }}"
170176
[ ! -z ${{ inputs.helmfileEnvironment }} ] && HELMFILE_PARAMS+=" -e ${{ inputs.helmfileEnvironment }}"
171177
[ ! -z ${{ inputs.helmfileOtherArgs }} ] && HELMFILE_PARAMS+=" ${{ inputs.helmfileOtherArgs }}"
172-
helmfile $HELMFILE_PARAMS sync
178+
helmfile $HELMFILE_PARAMS ${{ inputs.helmfileCommand }}
173179
174180
- name: helper - get slack message formatting
175181
id: helper
176-
if: ${{ always() }}
182+
if: always() && inputs.slackChannelId != ''
177183
run: |
178184
if [ "${{ job.status }}" = "success" ]
179185
then
@@ -185,15 +191,15 @@ jobs:
185191
fi
186192
187193
- name: send result to slack
188-
if: ${{ always() }}
194+
if: always() && inputs.slackChannelId != ''
189195
uses: slackapi/slack-github-action@v1.19.0
190196
env:
191197
SLACK_BOT_TOKEN: ${{ secrets.slackToken }}
192198
with:
193199
channel-id: ${{ inputs.slackChannelId }}
194200
payload: |
195201
{
196-
"text": ":${{ steps.helper.outputs.emoji }}: *${{ github.repository }} deploy result: ${{ job.status }}*",
202+
"text": ":${{ steps.helper.outputs.emoji }}: *${{ github.repository }} deploy of helmfile result: ${{ job.status }}*",
197203
"attachments": [
198204
{
199205
"color": "${{ steps.helper.outputs.color }}",
@@ -207,7 +213,7 @@ jobs:
207213
},
208214
{
209215
"type": "mrkdwn",
210-
"text": "*Revision:* ${{ inputs.imageTag }}"
216+
"text": "*Revision:* ${{ inputs.revision }}"
211217
},
212218
{
213219
"type": "mrkdwn",

.github/workflows/get_values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
id: get_short_commit_sha
3030
run: |
3131
if [ "${{ inputs.commitSha }}" != "" ]; then
32-
COMMIT_SHA=${{ inputs.commitSha }}
32+
COMMIT_SHA=${{ inputs.commitSha }}
3333
elif [ "${{ github.event_name }}" = "pull_request" ]; then
3434
COMMIT_SHA=${{ github.event.pull_request.head.sha }}
3535
else

0 commit comments

Comments
 (0)