From f4e00ca065d889158572c1881a33ad2621d6fd73 Mon Sep 17 00:00:00 2001 From: nico-iaco Date: Sun, 13 Oct 2024 21:48:46 +0100 Subject: [PATCH] updated github actions version --- .github/workflows/gcp.yml | 117 +++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/.github/workflows/gcp.yml b/.github/workflows/gcp.yml index 565946a..c99c726 100644 --- a/.github/workflows/gcp.yml +++ b/.github/workflows/gcp.yml @@ -1,62 +1,65 @@ --- name: Build and Push Image to Google Cloud Platform on: - push: - branches: [ master ] - paths-ignore: - - 'k8s/**' - - '.github/workflows/gradle-test.yml' - - '.github/workflows/docker-publish.yml' - - '.github/workflows/codacy.yml' - - 'docs/**' - - 'README.md' - - 'LICENSE' - - 'CHANGELOG.md' - - 'CODE_OF_CONDUCT.md' - - 'CONTRIBUTING.md' - - 'SECURITY.md' + push: + branches: [ master ] + paths-ignore: + - 'k8s/**' + - '.github/workflows/gradle-test.yml' + - '.github/workflows/docker-publish.yml' + - '.github/workflows/codacy.yml' + - 'docs/**' + - 'README.md' + - 'LICENSE' + - 'CHANGELOG.md' + - 'CODE_OF_CONDUCT.md' + - 'CONTRIBUTING.md' + - 'SECURITY.md' jobs: - build-push-gcr: - name: Build and Push to GCP - runs-on: ubuntu-latest + build-push-gcr: + name: Build and Push to GCP + runs-on: ubuntu-latest + env: + IMAGE_NAME: grocery-be + LOCATION: us-central1-docker.pkg.dev + PROJECT_ID: foody-me + REPOSITORY: foody-ar + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: benjlevesque/short-sha@v3.0 + id: short-sha + with: + length: 7 + - uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }} + - uses: google-github-actions/setup-gcloud@v2 + with: + project_id: ${{ env.PROJECT_ID }} + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + - name: Setup Gradle and execute 'bootBuildImage' task + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: "current" + arguments: bootBuildImage -Dspring.profiles.active=gcp --imageName=$IMAGE_NAME:latest env: - IMAGE_NAME: grocery-be - LOCATION: us-central1-docker.pkg.dev - PROJECT_ID: foody-me - REPOSITORY: foody-ar - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: benjlevesque/short-sha@v3.0 - id: short-sha - with: - length: 7 - - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }} - - uses: google-github-actions/setup-gcloud@v2 - with: - project_id: ${{ env.PROJECT_ID }} - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - - name: Setup Gradle and execute 'bootBuildImage' task - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: "current" - arguments: bootBuildImage -Dspring.profiles.active=gcp --imageName=$IMAGE_NAME:latest -# - name: Execute Gradle bootBuildImage task -# run: gradle -Dspring.profiles.active=gcp bootBuildImage --imageName=$IMAGE_NAME:latest -# env: -# SHORT_SHA: ${{ steps.short-sha.outputs.sha }} - - name: Configure Docker Client - run: |- - gcloud auth configure-docker $LOCATION --quiet - - name: Push Docker Image to Artifact Registry - run: |- - docker tag $IMAGE_NAME:latest $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:latest - docker tag $IMAGE_NAME:latest $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:$SHA - docker push $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:latest - docker push $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:$SHA \ No newline at end of file + SHORT_SHA: ${{ steps.short-sha.outputs.sha }} + IMAGE_NAME: ${{ env.IMAGE_NAME }} + # - name: Execute Gradle bootBuildImage task + # run: gradle -Dspring.profiles.active=gcp bootBuildImage --imageName=$IMAGE_NAME:latest + # env: + # SHORT_SHA: ${{ steps.short-sha.outputs.sha }} + - name: Configure Docker Client + run: |- + gcloud auth configure-docker $LOCATION --quiet + - name: Push Docker Image to Artifact Registry + run: |- + docker tag $IMAGE_NAME:latest $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:latest + docker tag $IMAGE_NAME:latest $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:$SHA + docker push $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:latest + docker push $LOCATION/$PROJECT_ID/$REPOSITORY/$IMAGE_NAME:$SHA \ No newline at end of file