Skip to content

Commit

Permalink
Use long form of variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sshrihar committed Mar 18, 2024
1 parent b2e4cbf commit bf40558
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ jobs:
id-token: write
contents: write
environment: ${{ needs.set-env-variable.outputs.ENVIRONMENT }}
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 @@ -58,14 +55,14 @@ jobs:
pip install pipenv && \
pipenv install && \
pipenv run python ".github/taskdefinition_template/taskdef_creator.py" \
.github/taskdef/${DEPLOY_ENV}-taskdef.yaml \
.github/taskdef/${{ needs.set-env-variable.outputs.ENVIRONMENT }}-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::${ACCOUNT_NUMBER}:role/static-${DEPLOY_ENV}-GithubActionsRole
role-to-assume: arn:aws:iam::${{ needs.set-env-variable.outputs.ACCOUNT_NUMBER }}:role/static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-GithubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
Expand All @@ -77,28 +74,28 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: "static-${DEPLOY_ENV}-ecr"
ECR_REPOSITORY: "static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-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-${DEPLOY_ENV}.json" >> $GITHUB_ENV
echo "TASKDEF_FILE=".github/taskdef/static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}.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-${DEPLOY_ENV}"
container-name: "static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}"
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-${DEPLOY_ENV}-ecs-service"
cluster: "static-${DEPLOY_ENV}-ecs-cluster"
service: "static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-ecs-service"
cluster: "static-${{ needs.set-env-variable.outputs.ENVIRONMENT }}-ecs-cluster"
wait-for-service-stability: true

0 comments on commit bf40558

Please sign in to comment.