Skip to content

Commit

Permalink
lets try google cloud run github action
Browse files Browse the repository at this point in the history
  • Loading branch information
joostvdg committed May 13, 2020
1 parent 4a2d4d1 commit eb3affb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 13 deletions.
63 changes: 51 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
branches:
- master

env:
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
RUN_REGION: europe-west4
SERVICE_NAME: cmg

jobs:
build:
name: build
Expand Down Expand Up @@ -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: "[email protected]:joostvdg/cmg.git"
# SOURCE_BRANCH: "master"
# DESTINATION_REPO: "[email protected]: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: "[email protected]:joostvdg/cmg.git"
SOURCE_BRANCH: "master"
DESTINATION_REPO: "[email protected]: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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM scratch
EXPOSE 8080
ENTRYPOINT ["/cmg"]
CMD ["serve"]
COPY ./bin/ /
COPY ./bin/ /usr/bin

0 comments on commit eb3affb

Please sign in to comment.