|
| 1 | +name: AWS ECR Push |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ['main'] |
| 5 | + release: |
| 6 | + types: ['published'] |
| 7 | +env: |
| 8 | + AWS_REGION: "us-east-1" |
| 9 | + AWS_ACCOUNT_ID: "886367452954" |
| 10 | +jobs: |
| 11 | + deploy: |
| 12 | + name: Push to ECR |
| 13 | + runs-on: ubuntu-latest |
| 14 | + # These permissions are needed to interact with GitHub's OIDC Token endpoint. |
| 15 | + permissions: |
| 16 | + id-token: write |
| 17 | + contents: read |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v2 |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@v1 |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v1 |
| 25 | + - name: Configure AWS credentials |
| 26 | + uses: aws-actions/configure-aws-credentials@v2 |
| 27 | + with: |
| 28 | + role-to-assume: arn:aws:iam::524386302118:role/Github.to.aws |
| 29 | + aws-region: ${{ env.AWS_REGION }} |
| 30 | + - name: Login to Amazon ECR |
| 31 | + id: login-ecr |
| 32 | + uses: aws-actions/amazon-ecr-login@v1 |
| 33 | + - name: Extract metadata (tags, labels) for Docker |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@v3 |
| 36 | + with: |
| 37 | + images: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ github.event.repository.name }} |
| 38 | + tags: | |
| 39 | + type=schedule,pattern=latest |
| 40 | + type=semver,pattern={{version}} |
| 41 | + type=semver,pattern={{major}}.{{minor}} |
| 42 | + type=semver,pattern={{major}} |
| 43 | + type=ref,event=branch |
| 44 | + - name: Build and push Docker image |
| 45 | + uses: docker/build-push-action@v2 |
| 46 | + with: |
| 47 | + context: . |
| 48 | + push: true |
| 49 | + platforms: linux/amd64,linux/arm64 |
| 50 | + tags: ${{ steps.meta.outputs.tags }} |
| 51 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments