Skip to content

Commit

Permalink
Update app number and secrets read through steps
Browse files Browse the repository at this point in the history
  • Loading branch information
sshrihar committed Mar 20, 2024
1 parent 927dedf commit d1fa878
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:

jobs:
deploy_workflow:
name: Deploy ${{ inputs.app_name }}
name: Deploy static
permissions:
id-token: write
contents: write
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
env:
APP_NAME: static-${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -36,7 +38,6 @@ jobs:
exit 1
;;
esac
echo "Account Number: $ACCOUNT_NUMBER"
- name: Create taskdef file dynamically using parameters passed
run: |
Expand All @@ -52,7 +53,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: eu-west-1
role-to-assume: arn:aws:iam::${{ needs.get_account_number.outputs.ACCOUNT_NUMBER }}:role/static-${{ inputs.environment }}-GithubActionsRole
role-to-assume: arn:aws:iam::${{ steps.get_account_number.outputs.ACCOUNT_NUMBER }}:role/$APP_NAME-GithubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
Expand All @@ -64,28 +65,28 @@ jobs:
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: "static-${{ inputs.environment }}-ecr"
ECR_REPOSITORY: "$APP_NAME-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/taskdefinition_template/static-${{ inputs.environment }}.json" >> $GITHUB_ENV
echo "TASKDEF_FILE=.github/taskdefinition_template/$APP_NAME.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-${{ inputs.environment }}"
container-name: "$APP_NAME"
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-${{ inputs.environment }}-ecs-service"
service: "$APP_NAME-ecs-service"
cluster: "frontend-${{ inputs.environment }}-ecs-cluster"
wait-for-service-stability: true

0 comments on commit d1fa878

Please sign in to comment.