gh: Try fixing docker push #5
This file contains 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: Frontend | |
on: | |
push: | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AWS_REGION: eu-west-1 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build | |
shell: bash | |
working-directory: frontend | |
run: | | |
docker build --rm . -t frontend | |
docker save -o /tmp/frontend_image.tar frontend | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: frontend_image | |
path: /tmp/frontend_image.tar | |
push: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-oidc-provider-aws | |
aws-region: ${{ env.AWS_REGION }} | |
- uses: aws-actions/amazon-ecr-login@v2 | |
id: login-ecr | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend_image | |
path: /tmp/ | |
- name: Push to ECR | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
REPOSITORY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/learning-frontend | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker load --input /tmp/frontend_image.tar | |
docker image tag frontend $REPOSITORY:$IMAGE_TAG | |
docker push $REPOSITORY:$IMAGE_TAG |