-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cloudrun deploy * deploy action * fixed typo * access token * direct identity * debug token * debug token request * revert debug * restore permissions * fix image location * authorize docker * fix image name * deploy staging/production * checkout step * fix vars * bump deployment * fix typo * add branch restriction
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: "Deploy to Cloud Run" | ||
|
||
on: | ||
push: | ||
branches: | ||
- v2 | ||
|
||
env: | ||
DOCKER_IMAGE_URL: ${{ vars.GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} | ||
GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} | ||
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | ||
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ env.SERVICE_ACCOUNT }} | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
project_id: ${{ env.PROJECT_ID }} | ||
|
||
- name: Docker Auth | ||
run: |- | ||
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | ||
docker build -t ${{ env.DOCKER_IMAGE_URL }} --file Dockerfile . | ||
docker push ${{ env.DOCKER_IMAGE_URL }} | ||
deploy-staging: | ||
needs: [build] | ||
environment: staging | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
- name: Deploy to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.GCP_SERVICE }} | ||
image: ${{ env.DOCKER_IMAGE_URL }} | ||
|
||
deploy-production: | ||
needs: [build] | ||
environment: production | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
- name: Deploy to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.GCP_SERVICE }} | ||
image: ${{ env.DOCKER_IMAGE_URL }} |