From eb3affbf648bf59090c901132aa83fa1493f72f0 Mon Sep 17 00:00:00 2001 From: Joost van der Griendt Date: Wed, 13 May 2020 21:59:52 +0200 Subject: [PATCH] lets try google cloud run github action --- .github/workflows/build.yml | 63 ++++++++++++++++++++++++++++++------- Dockerfile | 2 +- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7db6de..d51fba3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,11 @@ on: branches: - master +env: + PROJECT_ID: ${{ secrets.RUN_PROJECT }} + RUN_REGION: europe-west4 + SERVICE_NAME: cmg + jobs: build: name: build @@ -55,17 +60,51 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - sync-heroku: - needs: [build] +# sync-heroku: +# needs: [build] +# runs-on: ubuntu-latest +# steps: +# - name: repo-sync +# uses: wei/git-sync@master +# env: +# SOURCE_REPO: "git@github.com:joostvdg/cmg.git" +# SOURCE_BRANCH: "master" +# DESTINATION_REPO: "git@heroku.com:catan-map-generator.git" +# DESTINATION_BRANCH: "master" +# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} +# with: +# args: $SOURCE_REPO $SOURCE_BRANCH $DESTINATION_REPO $DESTINATION_BRANCH + + cloud-run: + name: Google Cloud Run runs-on: ubuntu-latest + steps: - - name: repo-sync - uses: wei/git-sync@master - env: - SOURCE_REPO: "git@github.com:joostvdg/cmg.git" - SOURCE_BRANCH: "master" - DESTINATION_REPO: "git@heroku.com:catan-map-generator.git" - DESTINATION_BRANCH: "master" - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - with: - args: $SOURCE_REPO $SOURCE_BRANCH $DESTINATION_REPO $DESTINATION_BRANCH + - name: Checkout + uses: actions/checkout@v2 + + # Setup gcloud CLI + - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master + with: + version: '290.0.1' + service_account_key: ${{ secrets.RUN_SA_KEY }} + project_id: ${{ secrets.RUN_PROJECT }} + + # Build and push image to Google Container Registry + - name: Build + run: |- + gcloud builds submit \ + --quiet \ + --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" + # Deploy image to Cloud Run + - name: Deploy + run: |- + gcloud run deploy "$SERVICE_NAME" \ + --quiet \ + --region "$RUN_REGION" \ + --image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \ + --platform "managed" \ + --allow-unauthenticated\ + --memory=128mb \ + --max-instances=2 \ + --timeout=30 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b0dd3f3..e863e6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM scratch EXPOSE 8080 ENTRYPOINT ["/cmg"] CMD ["serve"] -COPY ./bin/ / +COPY ./bin/ /usr/bin