Created
September 25, 2020 05:11
-
-
Save steelx/3d863ceff5ebe0a147b632ff93069991 to your computer and use it in GitHub Desktop.
Rust :: Build and Deploy to GCP
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: 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