Skip to content

Commit

Permalink
Update deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sshrihar committed Mar 18, 2024
1 parent e8be564 commit efb9e3e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
id-token: write
contents: write
environment: eu-west-1
env:
DEPLOY_ENV: ${{ needs.set-env-variable.outputs.ENVIRONMENT }}
ACCOUNT_NUMBER: ${{ needs.set-env-variable.outputs.ACCOUNT_NUMBER }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -55,14 +58,14 @@ jobs:
pip install pipenv && \
pipenv install && \
pipenv run python ".github/taskdefinition_template/taskdef_creator.py" \
.github/taskdef/${{ needs.set-env-variable.outputs.ENVIRONMENT }}-taskdef.yaml \
.github/taskdef/$DEPLOY_ENV-taskdef.yaml \
".github/taskdefinition_template/taskdef_template.json"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
role-to-assume: arn:aws:iam::${{ needs.set-env-variable.outputs.ACCOUNT_NUMBER }}:role/static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-GithubActionsRole
role-to-assume: arn:aws:iam::$ACCOUNT_NUMBER:role/static-$DEPLOY_ENV-GithubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
Expand All @@ -74,28 +77,28 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-ecr
ECR_REPOSITORY: static-$DEPLOY_ENV-ecr
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Extract directory path
run: |
echo "TASKDEF_FILE=".github/taskdef/static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}.json" >> $GITHUB_ENV
echo "TASKDEF_FILE=".github/taskdef/static-$DEPLOY_ENV.json" >> $GITHUB_ENV
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: "${{ env.TASKDEF_FILE }}"
container-name: static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}
container-name: static-$DEPLOY_ENV
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-ecs-service
cluster: static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-ecs-cluster
service: static-$DEPLOY_ENV-ecs-service
cluster: static-$DEPLOY_ENV-ecs-cluster
wait-for-service-stability: true

0 comments on commit efb9e3e

Please sign in to comment.