Merge pull request #103 from exercism/dependabot/github_actions/actio… #97
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: Push Docker images to DockerHub and ECR | |
| on: | |
| push: | |
| branches: [main, master] | |
| jobs: | |
| multiple-registries: | |
| runs-on: ubuntu-24.04 | |
| env: | |
| ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 2.3.4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # 3.11.1 | |
| - name: Cache Docker layers | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # 4.3.0 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Login to DockerHub | |
| uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # 3.5.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Login to ECR | |
| uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # 3.5.0 | |
| with: | |
| registry: ${{ env.ECR_REGISTRY }} | |
| username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }} | |
| password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 2.2.2 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ${{ github.event.repository.full_name }}:latest | |
| ${{ github.event.repository.full_name }}:${{ github.sha }} | |
| ${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:production | |
| ${{ env.ECR_REGISTRY }}/${{ github.event.repository.name }}:${{ github.sha }} | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache |