diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 220b2cb..69625c5 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -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 @@ -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 @@ -74,7 +77,7 @@ 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 @@ -82,20 +85,20 @@ jobs: - 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