diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 03a91654..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Manual Deploy to GCP -on: - workflow_dispatch: - inputs: - release: - description: 'Release version' - required: true -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - 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: Deploy Docker image - env: - release_version: ${{ github.event.inputs.release }} - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ github.event.inputs.release }} - run: | - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-latest --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="grailsforge-latest-cjmq3uyfcq-uc.a.run.app",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} - version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')" - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-$version --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="grailsforge-600-cjmq3uyfcq-uc.a.run.app",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} \ No newline at end of file diff --git a/.github/workflows/snapshot.yml b/.github/workflows/gradle.yml similarity index 61% rename from .github/workflows/snapshot.yml rename to .github/workflows/gradle.yml index 59761c24..af2fe78d 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/gradle.yml @@ -1,4 +1,4 @@ -name: "Snapshot" +name: "Java CI" on: push: branches: @@ -48,124 +48,6 @@ jobs: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} run: ./gradlew publishToSonatype - deploy: - # Snapshots should only be deployed from the latest release branch - # as it updates the snapshot version on https://start.grails.org. - if: false # github.event_name != 'pull_request' - name: "Deploy To Google Cloud Run" - runs-on: ubuntu-latest - needs: build - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:snapshot - steps: - - 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: "📥 Checkout repository" - uses: actions/checkout@v4 - - name: "☕️ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: 'liberica' - java-version: '17' - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "✅ Run Tests" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-api:test - grails-forge-web-netty:test - - name: "🔨 Build Docker image" - # To deploy native executables built with GraalVM replace dockerBuild with dockerBuildNative and dockerPush with dockerPushNative. First, try that it works locally. - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-web-netty:dockerBuildNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "📤 Push image to Google Cloud Container Registry" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-web-netty:dockerPushNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "🚀 Deploy Docker image" - run: > - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-snapshot - --image $IMAGE_NAME - --region us-central1 - --update-env-vars=HOSTNAME="snapshot.grails.org",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_SNAPSHOT_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_SNAPSHOT_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} - --platform managed - --allow-unauthenticated - --service-account=${{ secrets.GCLOUD_EMAIL }} - deployAnalytics: - # Snapshots should only be deployed from the latest release branch - # as it updates the snapshot version on https://start.grails.org. - if: false # github.event_name != 'pull_request' - name: "Deploy Analytics To Google Cloud Run" - runs-on: ubuntu-latest - needs: build - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:snapshot - steps: - - 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: "📥 Checkout repository" - uses: actions/checkout@v4 - - name: "☕️ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: 'liberica' - java-version: '17' - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "✅ Run Tests" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: ./gradlew grails-forge-analytics-postgres:test - - name: "🔨 Build Docker image" - # To deploy native executables built with GraalVM replace dockerBuild with dockerBuildNative and dockerPush with dockerPushNative. First, try that it works locally. - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-analytics-postgres:dockerBuildNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "📤 Push image to Google Cloud Container Registry" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-analytics-postgres:dockerPushNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "🚀 Deploy Docker image" - run: | - gcloud components install beta --quiet - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-snapshot --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} linux: name: "Build Linux Native CLI" runs-on: ubuntu-latest diff --git a/.github/workflows/prev.yml b/.github/workflows/prev-gcp-deploy.yml similarity index 99% rename from .github/workflows/prev.yml rename to .github/workflows/prev-gcp-deploy.yml index f939505a..9d57d32c 100644 --- a/.github/workflows/prev.yml +++ b/.github/workflows/prev-gcp-deploy.yml @@ -1,4 +1,4 @@ -name: "Prev" +name: "Prev GCP Deploy" on: workflow_dispatch: jobs: diff --git a/.github/workflows/release-gcp-deploy.yml b/.github/workflows/release-gcp-deploy.yml new file mode 100644 index 00000000..c9b83647 --- /dev/null +++ b/.github/workflows/release-gcp-deploy.yml @@ -0,0 +1,155 @@ +name: "Release GCP Deploy" +on: + workflow_dispatch: + inputs: + release: + description: 'Release version' + required: true +jobs: + build: + name: "Build Project" + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + release_version: ${{ github.event.inputs.release }} + env: + GIT_USER_NAME: 'grails-build' + GIT_USER_EMAIL: 'grails-build@users.noreply.github.com' + steps: + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "🔨 Build All" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: ./gradlew grails-cli:assemble + deploy: + name: "Deploy To Google Cloud Run" + runs-on: ubuntu-latest + needs: build + steps: + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + with: + ref: v${{ needs.build.outputs.release_version }} + - name: "🔑 Login to Google Cloud" + 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: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "✅ Run Tests" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-api:test + grails-forge-web-netty:test + - name: "🔨 Build Docker Native Image" + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-web-netty:dockerBuildNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "📤 Push image to Google Cloud Container Registry" + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-web-netty:dockerPushNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "🚀 Deploy Docker image" + env: + release_version: ${{ needs.build.outputs.release_version }} + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} + run: | + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-latest --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="latest.grails.org",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} + version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')" + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-$version --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="grailsforge-600-cjmq3uyfcq-uc.a.run.app",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} + deployAnalytics: + name: "Deploy Analytics To Google Cloud Run" + runs-on: ubuntu-latest + needs: build + steps: + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + with: + ref: v${{ needs.build.outputs.release_version }} + - 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: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "✅ Run Tests" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-analytics-postgres:test + - name: "🔨 Build Docker Native Image" + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:${{ needs.build.outputs.release_version }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-analytics-postgres:dockerBuildNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "📤 Push image to Google Cloud Container Registry" + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:${{ needs.build.outputs.release_version }} + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-analytics-postgres:dockerPushNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "🚀 Deploy Docker image" + env: + release_version: ${{ needs.build.outputs.release_version }} + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} + run: | + gcloud components install beta --quiet + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-latest --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} + 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 --service-account=${{ secrets.GCLOUD_EMAIL }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6fd2725b..0e772282 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -111,128 +111,6 @@ jobs: commit_user_email: ${{ env.GIT_USER_EMAIL }} commit_author: ${{ env.GIT_USER_NAME }} <${{ env.GIT_USER_EMAIL }}> file_pattern: gradle.properties - deploy: - name: "Deploy To Google Cloud Run" - runs-on: ubuntu-latest - needs: build - steps: - - name: "📥 Checkout repository" - uses: actions/checkout@v4 - with: - ref: v${{ needs.build.outputs.release_version }} - - name: "🔑 Login to Google Cloud" - 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: "☕️ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: 'liberica' - java-version: '11' - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "✅ Run Tests" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-api:test - grails-forge-web-netty:test - - name: "🔨 Build Docker image" - # To deploy native executables built with GraalVM replace dockerBuild with dockerBuildNative and dockerPush with dockerPushNative. First, try that it works locally. - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-web-netty:dockerBuildNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "📤 Push image to Google Cloud Container Registry" - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-web-netty:dockerPushNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "🚀 Deploy Docker image" - env: - release_version: ${{ needs.build.outputs.release_version }} - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} - run: | - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-latest --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="latest.grails.org",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} - version="$(echo "${release_version//./}" | tr '[A-Z]' '[a-z]')" - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-$version --image $IMAGE_NAME --region us-central1 --update-env-vars=HOSTNAME="grailsforge-600-cjmq3uyfcq-uc.a.run.app",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_LATEST_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_LATEST_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} - deployanalytics: - name: "Deploy Analytics To Google Cloud Run" - runs-on: ubuntu-latest - needs: build - steps: - - name: "📥 Checkout repository" - uses: actions/checkout@v4 - with: - ref: v${{ needs.build.outputs.release_version }} - - 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: "☕️ Setup JDK" - uses: actions/setup-java@v4 - with: - distribution: 'liberica' - java-version: '11' - - name: "🐘 Setup Gradle" - uses: gradle/actions/setup-gradle@v4 - with: - develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} - - name: "✅ Run Tests" - env: - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-analytics-postgres:test - - name: "🔨 Build Docker image" - # To deploy native executables built with GraalVM replace dockerBuild with dockerBuildNative and dockerPush with dockerPushNative. First, try that it works locally. - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:${{ needs.build.outputs.release_version }} - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-analytics-postgres:dockerBuildNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "📤 Push image to Google Cloud Container Registry" - env: - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:${{ needs.build.outputs.release_version }} - DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} - DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} - run: > - ./gradlew - grails-forge-analytics-postgres:dockerPushNative - -PdockerImageName=${{ env.IMAGE_NAME }} - - name: "🚀 Deploy Docker image" - env: - release_version: ${{ needs.build.outputs.release_version }} - IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:${{ needs.build.outputs.release_version }} - run: | - gcloud components install beta --quiet - gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-latest --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }} - 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 --service-account=${{ secrets.GCLOUD_EMAIL }} linux: name: "Release Linux Native CLI" runs-on: ubuntu-latest diff --git a/.github/workflows/snapshot-gcp-deploy.yml b/.github/workflows/snapshot-gcp-deploy.yml new file mode 100644 index 00000000..b55f4987 --- /dev/null +++ b/.github/workflows/snapshot-gcp-deploy.yml @@ -0,0 +1,135 @@ +name: "Snapshot GCP Deploy" +on: + workflow_dispatch: +jobs: + build: + name: "Build Project" + runs-on: ubuntu-latest + steps: + - name: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "🔨 Run Build" + id: build + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: ./gradlew build + deploy: + name: "Deploy To Google Cloud Run" + runs-on: ubuntu-latest + needs: build + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}:snapshot + steps: + - 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: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "✅ Run Tests" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-api:test + grails-forge-web-netty:test + - name: "🔨 Build Docker Native Image" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-web-netty:dockerBuildNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "📤 Push image to Google Cloud Container Registry" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-web-netty:dockerPushNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "🚀 Deploy Docker image" + run: > + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-snapshot + --image $IMAGE_NAME + --region us-central1 + --update-env-vars=HOSTNAME="snapshot.grails.org",CORS_ALLOWED_ORIGIN="https://start.grails.org",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_SNAPSHOT_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_SNAPSHOT_CLIENT_SECRET }},GITHUB_USER_AGENT=${{ secrets.GH_USER_AGENT }},GITHUB_REDIRECT_URL=${{ secrets.GH_REDIRECT_URL }} + --platform managed + --allow-unauthenticated + --service-account=${{ secrets.GCLOUD_EMAIL }} + deployAnalytics: + name: "Deploy Analytics To Google Cloud Run" + runs-on: ubuntu-latest + needs: build + env: + IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}-analytics:snapshot + steps: + - 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: "📥 Checkout repository" + uses: actions/checkout@v4 + - name: "☕️ Setup JDK" + uses: actions/setup-java@v4 + with: + distribution: 'liberica' + java-version: '11' + - name: "🐘 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + - name: "✅ Run Tests" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: ./gradlew grails-forge-analytics-postgres:test + - name: "🔨 Build Docker Native Image" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-analytics-postgres:dockerBuildNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "📤 Push image to Google Cloud Container Registry" + env: + DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }} + DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }} + run: > + ./gradlew + grails-forge-analytics-postgres:dockerPushNative + -PdockerImageName=${{ env.IMAGE_NAME }} + - name: "🚀 Deploy Docker image" + run: | + gcloud components install beta --quiet + gcloud run deploy ${{ secrets.GCP_PROJECT_ID }}-analytics-snapshot --image $IMAGE_NAME --region us-central1 --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }}