Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rust :: Build and Deploy to GCP
name: Build and Deploy to Google
on:
workflow_dispatch:
# Environment variables available to all jobs and steps in this workflow
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GITHUB_SHA: ${{ github.sha }}
RUN_REGION: asia-southeast1
SERVICE_NAME: discord-zbot
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '290.0.1'
service_account_email: ${{ secrets.SA_EMAIL }}
service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS}}
export_default_credentials: true
project_id: ${{ secrets.GCP_PROJECT_ID }}
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
pwd
ls -a
gcloud info
- name: Build API
run: |
cd .
echo $GCP_PROJECT_ID
echo ${{ secrets.SA_EMAIL }}
gcloud builds submit -t gcr.io/$GCP_PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA
- name: Deploy API
run: |
cd .
gcloud run deploy $SERVICE_NAME \
--region $RUN_REGION \
--image gcr.io/$GCP_PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA \
--platform managed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.