cloud run deployment #568
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cloud run deployment | |
on: | |
workflow_run: | |
workflows: | |
- tests | |
types: | |
- completed | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} | |
steps: | |
- name: Checkout repository code | |
uses: actions/checkout@v3 | |
- name: Inject keys | |
run: | | |
echo -en '${{ secrets.KEYS_YAML }}' >> keys.yaml | |
- name: Authenticate GCP | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
- name: Remove tests directory | |
run: rm -r tests | |
- name: Build Docker image | |
run: | | |
docker build -t jeeves . | |
- name: Push Docker image to GCP Container Registry | |
run: | | |
gcloud auth configure-docker | |
docker tag jeeves gcr.io/preritdas-api/jeeves | |
docker push gcr.io/preritdas-api/jeeves | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ needs.build.result == 'success' }} | |
steps: | |
- name: Authenticate GCP | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
- name: Deploy to Cloud Run | |
uses: 'google-github-actions/deploy-cloudrun@v1' | |
with: | |
service: 'jeeves' | |
image: gcr.io/preritdas-api/jeeves | |
flags: '--min-instances=0 --cpu=2 --memory=4Gi --timeout=5m --allow-unauthenticated --no-cpu-throttling --cpu-boost' | |
no_traffic: false | |
- name: Allocate traffic to latest deployment | |
run: gcloud run services update-traffic --region us-central1 --to-latest jeeves |