Merge pull request #8 from Profect-4th-IRUM/chore/#4-dockerization #3
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: ecr_cd_tmp.yml | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Image Tag to use' | |
| required: false | |
| default: 'latest' | |
| env: | |
| AWS_REGION: ap-northeast-2 | |
| ECR_REGISTRY: public.ecr.aws/k5m3t9y9 | |
| ECR_REPOSITORY: come2us-gateway | |
| IMAGE_TAG: ${{ github.sha }} | |
| jobs: | |
| build-and-push-to-ecr: | |
| name: Build, Tag, and Push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR Public | |
| id: login-ecr-public | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| with: | |
| registry-type: public | |
| - name: Build, Tag, and push the image to ECR | |
| id: build-image | |
| env: | |
| ECR_URL: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }} | |
| run: | | |
| IMAGE_LATEST_TAG=${{ env.ECR_URL }}:latest | |
| IMAGE_SHA_TAG=${{ env.ECR_URL }}:${{ env.IMAGE_TAG }} | |
| docker build -t $IMAGE_LATEST_TAG . | |
| docker tag $IMAGE_LATEST_TAG $IMAGE_SHA_TAG | |
| docker push $IMAGE_LATEST_TAG | |
| docker push $IMAGE_SHA_TAG |