@@ -3,6 +3,30 @@ name: deploy helmfile
33on :
44 workflow_call :
55 inputs :
6+ awsRoleArn :
7+ description : AWS IAM role ARN
8+ required : false
9+ type : string
10+ useOIDC :
11+ description : Whether to use OIDC for assume role
12+ required : false
13+ type : boolean
14+ default : false
15+ githubOIDCRoleArn :
16+ description : Github OIDC role ARN
17+ required : false
18+ type : string
19+ default : " "
20+ awsRegion :
21+ description : AWS region
22+ required : false
23+ type : string
24+ default : us-east-1
25+ awsSessionDuration :
26+ description : AWS session duration
27+ required : false
28+ type : number
29+ default : 3600
630 revision :
731 description : Tag given to container image
832 required : true
2347 description : Other helmfile parameters
2448 required : false
2549 type : string
26- awsRoleArn :
27- description : AWS IAM role ARN
28- required : false
29- type : string
30- awsRegion :
31- description : AWS region
32- required : false
33- type : string
34- default : us-east-1
35- awsSessionDuration :
36- description : AWS session duration
37- required : false
38- type : number
39- default : 3600
4050 envVariables :
4151 description : Space separated list of environment variables to be set during helmfile apply
4252 required : false
6373 required : false
6474 default : true
6575 type : string
76+ runner :
77+ description : Runner to use
78+ required : false
79+ type : string
80+ default : ubuntu-22.04
81+
6682
6783 secrets :
6884 awsAccessKeyId :
6985 description : AWS access key ID
70- required : true
86+ required : false
7187 awsSecretAccessKey :
7288 description : AWS secret access key
73- required : true
89+ required : false
7490 slackToken :
7591 description : Slack API token
7692 required : false
89105
90106jobs :
91107 deploy :
92- runs-on : ubuntu-latest
108+ runs-on : ${{ inputs.runner }}
93109 steps :
94110 - name : clone repository
95111 uses : actions/checkout@v4
@@ -141,29 +157,32 @@ jobs:
141157 # NOTE: This will go away with terraform
142158 - name : setup dependencies
143159 env :
144- # TODD: remove eksctl as it is not used anymore
145- EKSCTL_VERSION : v0.98.0
146160 # renovate: datasource=github-releases depName=helmfile/helmfile
147- HELMFILE_VERSION : ' v0.155.1 '
161+ HELMFILE_VERSION : ' v0.171.0 '
148162 # renovate: datasource=github-releases depName=databus23/helm-diff
149163 HELM_DIFF_PLUGIN_VERSION : v3.9.6
150164 run : |
151165 HELMFILE_VERSION_WITHOUT_PREFIX=${HELMFILE_VERSION:1}
152- curl -fsSL -o eksctl.tar.gz https://github.com/weaveworks/eksctl/releases/download/${{ env.EKSCTL_VERSION }}/eksctl_Linux_amd64.tar.gz
153- curl -fsSL -o helmfile.tar.gz https://github.com/helmfile/helmfile/releases/download/${{ env.HELMFILE_VERSION }}/helmfile_${HELMFILE_VERSION_WITHOUT_PREFIX}_linux_amd64.tar.gz
166+
167+ # Determine architecture based on runner
168+ ARCH="amd64"
169+ if [[ "${{ inputs.runner }}" == *"arm"* ]]; then
170+ ARCH="arm64"
171+ fi
172+
173+ curl -fsSL -o helmfile.tar.gz https://github.com/helmfile/helmfile/releases/download/${{ env.HELMFILE_VERSION }}/helmfile_${HELMFILE_VERSION_WITHOUT_PREFIX}_linux_${ARCH}.tar.gz
154174
155175 helm plugin install https://github.com/databus23/helm-diff --version ${{ env.HELM_DIFF_PLUGIN_VERSION }}
156176
157177 mkdir -p $HOME/.local/bin
158178
159- tar -C $HOME/.local/bin/ -xf ./eksctl.tar.gz
160179 tar -C $HOME/.local/bin/ -xf ./helmfile.tar.gz
161180
162181 chmod +x $HOME/.local/bin/*
163182 echo "$HOME/.local/bin" >> $GITHUB_PATH
164183
165184 - name : assume IAM role
166- if : inputs.awsRoleArn != ''
185+ if : inputs.useOIDC == false
167186 uses : aws-actions/configure-aws-credentials@v4
168187 with :
169188 aws-access-key-id : ${{ secrets.awsAccessKeyId }}
@@ -176,6 +195,30 @@ jobs:
176195 # which does not work for cross-account assume
177196 role-skip-session-tagging : true
178197
198+ # First assume GithubOIDCRole role, the trust relationship between GitHub and AWS is defined in IAM GithubOIDCRole in the organization account. This role has permissions to assume Deployer roles only.
199+ - name : assume GithubOIDCRole
200+ if : inputs.useOIDC == true
201+ uses : aws-actions/configure-aws-credentials@v4
202+ with :
203+ aws-region : ${{ inputs.awsRegion }}
204+ role-to-assume : ${{ inputs.githubOIDCRoleArn }}
205+ role-duration-seconds : ${{ inputs.awsSessionDuration }}
206+
207+ # This parameter is needed otherwise this action is trying to tag session
208+ # which does not work for cross-account assume
209+ role-skip-session-tagging : true
210+
211+ # Then assume Deployer role, which can be assumed by GithubOIDCRole and has all the permissions needed to deploy cloudformation stacks.
212+ - name : assume Deployer role
213+ if : inputs.useOIDC == true
214+ uses : aws-actions/configure-aws-credentials@v4
215+ with :
216+ aws-region : ${{ inputs.awsRegion }}
217+ role-to-assume : ${{ inputs.awsRoleArn }}
218+ role-duration-seconds : ${{ inputs.awsSessionDuration }}
219+ role-chaining : true
220+ role-skip-session-tagging : true
221+
179222 - name : setup kubeconfig
180223 run : aws eks update-kubeconfig --name ${{ inputs.eksClusterName }} $OPTIONAL_PARAMS
181224
0 commit comments