Update google-cloudrun-docker.yml #17
This file contains hidden or 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: Deploy Angular Blog to Cloud Run | |
| on: | |
| push: | |
| branches: | |
| - main # or any other branch you use for production | |
| jobs: | |
| test: | |
| name: Run Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run unit tests with headless Chrome | |
| run: npm run test -- --browsers=ChromeHeadless --watch=false --no-progress | |
| continue-on-error: false | |
| # The workflow will fail if tests throw an error or fail | |
| deploy: | |
| name: Build and Deploy | |
| runs-on: ubuntu-latest | |
| needs: test # This makes deploy job dependent on the test job | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build Angular app | |
| run: npm run build --prod | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
| - name: Install Google Cloud SDK | |
| run: | | |
| echo "Installing Google Cloud SDK" | |
| echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | |
| sudo apt-get install -y apt-transport-https ca-certificates | |
| sudo apt-get update && sudo apt-get install -y google-cloud-sdk | |
| gcloud version | |
| - name: Deploy to Cloud Run using Buildpacks | |
| uses: google-github-actions/deploy-cloudrun@v2 | |
| with: | |
| service: angular-blog # your Cloud Run service name | |
| region: europe-central2 # match to your region | |
| source: . |