From bf8b8a7ec7cddea6328d4ab9673e9ba6ff492954 Mon Sep 17 00:00:00 2001 From: Matthias Kutz Date: Thu, 9 Jan 2025 15:36:21 +0100 Subject: [PATCH] Add workflow to push ecr repository --- .github/workflows/build_and_push_to_ecr.yml | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/build_and_push_to_ecr.yml diff --git a/.github/workflows/build_and_push_to_ecr.yml b/.github/workflows/build_and_push_to_ecr.yml new file mode 100644 index 0000000..7cf9a15 --- /dev/null +++ b/.github/workflows/build_and_push_to_ecr.yml @@ -0,0 +1,52 @@ +name: build release and push to ECR +on: + release: + types: [prereleased, released] +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Public ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + username: ${{ secrets.AWS_PROD_ECR_VIADEE_ACCESS_KEY_ID }} + password: ${{ secrets.AWS_PROD_ECR_VIADEE_SECRET_ACCESS_KEY }} + env: + AWS_REGION: us-east-1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "adopt" # See 'Supported distributions' for available options + cache: 'maven' + + - name: Maven build image + run: mvn install -Dquarkus.native.container-build=true + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: public.ecr.aws/m4k8r3n4/viadee-quarkus-todo-app + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Push Docker images + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file