mirror of
https://github.com/google-github-actions/setup-gcloud.git
synced 2026-08-28 16:09:21 +00:00
* Refactor * add merge * linting * update setup * Update tests * Add more e2e tests * update workflow var * fix typo * Test workflow * refactor tests * Add clean up * Add step * fix env vars * Fix typo * fix readme * update name * remove dist * remove dist * fix dep * Other IT run on push only
161 lines
5.5 KiB
YAML
161 lines
5.5 KiB
YAML
name: deploy-cloudrun Integration
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'deploy-cloudrun/**'
|
|
- '.github/workflows/deploy-cloudrun-it.yml'
|
|
|
|
jobs:
|
|
envvars:
|
|
name: with Env Vars
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: service
|
|
run: echo ::set-output name=service::run-envvars-$GITHUB_SHA
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@master
|
|
with:
|
|
node-version: 12.x
|
|
- name: Build Javascript
|
|
working-directory: ./deploy-cloudrun
|
|
run: |-
|
|
npm install
|
|
npm run build
|
|
- name: Create Service with one env var
|
|
id: deploy_1
|
|
uses: ./deploy-cloudrun
|
|
with:
|
|
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
|
|
image: gcr.io/cloudrun/hello
|
|
service: ${{ steps.service.outputs.service }}
|
|
env_vars: TEST_ENV=TEST_VAR
|
|
- name: Setup Authentication with gcloud
|
|
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
|
with:
|
|
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
|
|
export_default_credentials: true
|
|
- name: Integration Tests
|
|
run: npm run e2e-tests
|
|
working-directory: ./deploy-cloudrun
|
|
env:
|
|
URL: ${{ steps.deploy_1.outputs.url }}
|
|
SERVICE: ${{ steps.service.outputs.service }}
|
|
ENV: TEST_ENV=TEST_VAR
|
|
- name: Update Service with second env var
|
|
id: deploy_2
|
|
uses: ./deploy-cloudrun
|
|
with:
|
|
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
|
|
image: gcr.io/cloudrun/hello
|
|
service: ${{ steps.service.outputs.service }}
|
|
env_vars: TEST_ENV2=TEST_VAR2
|
|
- name: Integration Tests # Check that config isn't overwritten
|
|
run: npm run e2e-tests
|
|
working-directory: ./deploy-cloudrun
|
|
env:
|
|
URL: ${{ steps.deploy_2.outputs.url }}
|
|
SERVICE: ${{ steps.service.outputs.service }}
|
|
ENV: TEST_ENV=TEST_VAR,TEST_ENV2=TEST_VAR2
|
|
|
|
yaml:
|
|
name: with YAML metadata
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: service
|
|
run: echo ::set-output name=service::run-yaml-$GITHUB_SHA
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@master
|
|
with:
|
|
node-version: 12.x
|
|
- name: Build Javascript
|
|
working-directory: ./deploy-cloudrun
|
|
run: |-
|
|
npm install
|
|
npm run build
|
|
- name: Deploy Service
|
|
id: deploy
|
|
uses: ./deploy-cloudrun
|
|
with:
|
|
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
|
|
service: ${{ steps.service.outputs.service }}
|
|
metadata: ./deploy-cloudrun/tests/unit/service.basic.yaml
|
|
- name: Setup Authentication with gcloud
|
|
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
|
with:
|
|
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
|
|
export_default_credentials: true
|
|
- name: Integration Tests
|
|
run: npm run e2e-tests
|
|
working-directory: ./deploy-cloudrun
|
|
env:
|
|
URL: ${{ steps.deploy.outputs.url }}
|
|
|
|
metadata:
|
|
name: with full YAML metada
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: service
|
|
run: echo ::set-output name=service::run-full-yaml-$GITHUB_SHA
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@master
|
|
with:
|
|
node-version: 12.x
|
|
- name: Build Javascript
|
|
working-directory: ./deploy-cloudrun
|
|
run: |-
|
|
npm install
|
|
npm run build
|
|
- name: Create service from metadata yaml
|
|
id: deploy_1
|
|
uses: ./deploy-cloudrun
|
|
with:
|
|
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
|
|
service: ${{ steps.service.outputs.service }}
|
|
metadata: ./deploy-cloudrun/tests/unit/service.full.yaml
|
|
- name: Setup Authentication with gcloud
|
|
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
|
with:
|
|
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
|
|
export_default_credentials: true
|
|
- name: Integration Tests
|
|
run: npm run e2e-tests
|
|
working-directory: ./deploy-cloudrun
|
|
env:
|
|
URL: ${{ steps.deploy_1.outputs.url }}
|
|
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
|
|
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
|
|
LABELS: "{\"test_label\": \"test_value\"}"
|
|
- name: Update service with new image
|
|
id: deploy_2
|
|
uses: ./deploy-cloudrun
|
|
with:
|
|
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
|
|
image: gcr.io/cloudrun/hello
|
|
service: ${{ steps.service.outputs.service }}
|
|
- name: Integration Tests # Check that config isn't overwritten
|
|
run: npm run e2e-tests
|
|
working-directory: ./deploy-cloudrun
|
|
env:
|
|
URL: ${{ steps.deploy_2.outputs.url }}
|
|
SERVICE: ${{ steps.service.outputs.service }}
|
|
PARAMS: "{\"cpu\": 2,\"memory\": \"1Gi\", \"containerConcurrency\": 20}"
|
|
ANNOTATIONS: "{\"run.googleapis.com/cloudsql-instances\": \"1:2:3\"}"
|
|
LABELS: "{\"test_label\": \"test_value\"}"
|
|
|
|
cleanup:
|
|
name: Clean Up
|
|
runs-on: ubuntu-latest
|
|
needs: [envvars, metadata, yaml]
|
|
steps:
|
|
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
|
|
with:
|
|
service_account_key: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_B64 }}
|
|
project_id: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
|
|
- name: Delete services
|
|
run: |-
|
|
gcloud config set run/platform managed
|
|
gcloud config set run/region us-central1
|
|
gcloud run services delete run-full-yaml-$GITHUB_SHA --quiet
|
|
gcloud run services delete run-yaml-$GITHUB_SHA --quiet
|
|
gcloud run services delete run-envvars-$GITHUB_SHA --quiet
|