Merge pull request #1 from RieBi/ci-cd #16
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: DeployCountrie | |
on: | |
push: | |
branches: [ "master" ] | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
env: | |
ConnectionStrings__PostgreConnectionRelease: ${{ secrets.DATABASE_CONNECTION }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: 'Copy Dockerfile to root' | |
run: cp Web/Dockerfile ./Dockerfile | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
- name: 'Use gcloud CLI' | |
run: 'gcloud info' | |
- name: 'Build the docker image' | |
run: 'gcloud builds submit --tag europe-central2-docker.pkg.dev/countrie/repo/countrie:latest .' | |
- name: 'Deploy to Cloud Run' | |
run: 'gcloud run deploy countrie --image europe-central2-docker.pkg.dev/countrie/repo/countrie:latest --region europe-central2 --allow-unauthenticated --project countrie --max-instances=4 --update-env-vars=ConnectionStrings__PostgreConnectionRelease="${{ secrets.DATABASE_CONNECTION }}"' |