From a143e8d162ff9bbfd163f9eb9e25cbd8d161d624 Mon Sep 17 00:00:00 2001 From: Bane Sullivan Date: Thu, 3 Oct 2024 22:25:09 -0700 Subject: [PATCH] Push Docker image to AWS ECR --- .github/workflows/ecr.yml | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/ecr.yml diff --git a/.github/workflows/ecr.yml b/.github/workflows/ecr.yml new file mode 100644 index 0000000..128ff99 --- /dev/null +++ b/.github/workflows/ecr.yml @@ -0,0 +1,45 @@ +name: ECR Package +on: + workflow_dispatch: + push: + tags: + - "*" + branches: + - main + +env: + IMAGE_NAME: localtileserver + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-west-2 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }} + tags: | + # set latest tag for main branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + - name: Build and push the Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max