-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Deploy Lampi-siirtäjä | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image-tag: | ||
description: 'Image tag deployed (example: ga-21).' | ||
required: true | ||
type: string | ||
environment: | ||
type: string | ||
required: true | ||
description: 'Environment which to deploy to (testi/tuotanto)' | ||
workflow_dispatch: | ||
inputs: | ||
image-tag: | ||
description: 'Image tag deployed (example: ga-21).' | ||
required: true | ||
type: string | ||
environment: | ||
type: choice | ||
description: 'Environment which to deploy to' | ||
options: | ||
- testi | ||
- tuotanto | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy Lampi-siirtäjä from ECR to ECS | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Configure AWS credentials | ||
if: ${{ inputs.environment == 'testi' }} | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_OVARA_TESTI_ROLE_ARN }} | ||
role-session-name: testi-lampi-siirtaja-deploy | ||
aws-region: eu-west-1 | ||
|
||
- name: Configure AWS credentials | ||
if: ${{ inputs.environment == 'tuotanto' }} | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_OVARA_TUOTANTO_ROLE_ARN }} | ||
role-session-name: tuotanto-lampi-siirtaja-deploy | ||
aws-region: eu-west-1 | ||
|
||
- name: Configure ENV parameters | ||
if: ${{ inputs.environment == 'testi' }} | ||
run: | | ||
echo "FAMILY_PREFIX=testiEcsStacktestiovaralampisiirtajaScheduledTaskDef" >> $GITHUB_ENV | ||
echo "ECS_CLUSTER_NAME=testi-ecs-cluster" >> $GITHUB_ENV | ||
echo "SCHEDULED_TASK_RULE_PREFIX=testi-lampiSiirtajaScheduledFargateTaskRule" >> $GITHUB_ENV | ||
- name: Configure ENV parameters | ||
if: ${{ inputs.environment == 'tuotanto' }} | ||
run: | | ||
echo "FAMILY_PREFIX=tuotantoEcsStacktestiovaralampisiirtajaScheduledTaskDef" >> $GITHUB_ENV | ||
echo "ECS_CLUSTER_NAME=tuotanto-ecs-cluster" >> $GITHUB_ENV | ||
echo "SCHEDULED_TASK_RULE_PREFIX=tuotanto-lampiSiirtajaScheduledFargateTaskRule" >> $GITHUB_ENV | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition `aws ecs list-task-definition-families --family-prefix ${{ env.FAMILY_PREFIX }} | jq -r '.families[0]'` --query taskDefinition > task-definition.json | ||
echo $(cat task-definition.json | jq 'del( | ||
.taskDefinitionArn, | ||
.requiresAttributes, | ||
.compatibilities, | ||
.revision, | ||
.status, | ||
.registeredAt, | ||
.registeredBy | ||
)' ) > task-definition.json | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/[email protected] | ||
with: | ||
task-definition: task-definition.json | ||
container-name: ScheduledContainer | ||
image: ${{ secrets.AWS_OVARA_UTILITY_ECR_LAMPI_SIIRTAJA_REPO }}:${{ inputs.image-tag }} | ||
|
||
- name: Deploy to Amazon ECS Scheduled Tasks | ||
uses: airfordable/[email protected] | ||
with: | ||
cluster: ${{ env.ECS_CLUSTER_NAME }} | ||
rule-prefix: ${{ env.SCHEDULED_TASK_RULE_PREFIX }} | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
|
||
- name: Update container image version to AWS Parameter store | ||
run: | | ||
aws ssm put-parameter --name "/${{ inputs.environment }}/ecs/lampi-siirtaja/version" --type "String" --value "${{ inputs.image-tag }}" --overwrite |