From b9e1bb14aa73e7c4e51ef7a967e2c88c3398e579 Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Mon, 26 Jun 2023 13:41:22 +0200 Subject: [PATCH] add deploy analytics step to release workflow --- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7caffe2..d1c80be2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,6 +130,48 @@ jobs: gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-latest --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')" gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-$version --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated + deployanalytics: + name: Deploy Analytics To Google Cloud Run + runs-on: ubuntu-latest + needs: [build] + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set the current release version + id: release_version + run: | + release_version=${GITHUB_REF:11} + sed -i "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties + echo "release_version=${release_version}" >> $GITHUB_OUTPUT + - name: Login + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + service_account_email: ${{ secrets.GCP_EMAIL }} + service_account_key: ${{ secrets.GCP_CREDENTIALS }} + - name: Configure Docker + run: gcloud auth configure-docker --quiet + - name: Set up JDK + uses: actions/setup-java@v3.11.0 + with: + distribution: 'adopt' + java-version: '11' + - name: Run Tests + run: ./gradlew grails-forge-analytics-postgres:test + - name: Build and Push Docker image and deploy to Cloud Run + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:${{ steps.release_version.outputs.release_version }} + # To deploy native executables built with GraalVM replace dockerBuild with dockerBuildNative and dockerPush with dockerPushNative. First, try that it works locally. + run: | + ./gradlew grails-forge-analytics-postgres:dockerBuild -PdockerImageName="$IMAGE_NAME" + ./gradlew grails-forge-analytics-postgres:dockerPush -PdockerImageName="$IMAGE_NAME" + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-latest --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated + version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')" + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-$version --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated linux: name: Release Linux Native CLI runs-on: ubuntu-latest