squash history #10
This file contains hidden or 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
| name: Build and Publish Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| permissions: | |
| id-token: write # This is required for requesting the JWT | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: configure aws credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::654654236858:role/GithubActions | |
| role-session-name: GitHub_to_AWS_via_FederatedOIDC | |
| aws-region: us-east-2 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build and Push Docker image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}} | |
| REPOSITORY: ud-repo | |
| IMAGE_TAG: ${{ github.sha}} | |
| run: | | |
| # Build a docker container and | |
| # push it to ECR so that it can | |
| # be deployed to ECS. | |
| docker build -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG . | |
| docker build -t $ECR_REGISTRY/$REPOSITORY:prod . | |
| docker push $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG | |
| docker push $ECR_REGISTRY/$REPOSITORY:prod | |
| echo "image=$ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| echo "image=$ECR_REGISTRY/$REPOSITORY:prod" >> $GITHUB_OUTPUT |