Mixonomer.NET/.github/workflows/ci.yml
2024-01-21 20:50:51 +00:00

89 lines
2.7 KiB
YAML

name: ci
on: [push]
env:
dotnet-version: '8.0.x'
jobs:
build:
runs-on: ubuntu-latest
name: Build & Unit Test
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK ${{ env.dotnet-version }}
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: ${{ env.dotnet-version }}
- name: Install Dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
deploytest:
runs-on: ubuntu-latest
name: Deploy Test
environment:
name: test
url: https://test.mixonomer.sarsoo.xyz
needs: build # for ignoring bad builds
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3 # get source
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0.7.3
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
export_environment_variables: true
create_credentials_file: true
- name: Deploy RunUserPlaylist
run: |
gcloud functions deploy RunUserPlaylist \
--region europe-west2 \
--gen2 \
--runtime=dotnet8 \
--entry-point Mixonomer.Func.RunUserPlaylist \
--trigger-topic run_user_playlist \
--set-env-vars GOOGLE_CLOUD_PROJECT=${{ vars.GCP_PROJECT }} \
--service-account runuserplaylist-func@${{ vars.GCP_PROJECT }}.iam.gserviceaccount.com \
--set-build-env-vars=GOOGLE_BUILDABLE=Mixonomer.Func
shell: bash
deployprod:
runs-on: ubuntu-latest
name: Deploy Production
environment:
name: prod
url: https://mixonomer.sarsoo.xyz
needs: deploytest # for ignoring bad builds
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3 # get source
- name: Set up Cloud SDK
uses: google-github-actions/auth@v0.7.3
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
export_environment_variables: true
create_credentials_file: true
- name: Deploy RunUserPlaylist
run: |
gcloud functions deploy RunUserPlaylist \
--region europe-west2 \
--gen2 \
--runtime=dotnet8 \
--entry-point Mixonomer.Func.RunUserPlaylist \
--trigger-topic run_user_playlist \
--set-env-vars GOOGLE_CLOUD_PROJECT=${{ vars.GCP_PROJECT }} \
--service-account runuserplaylist-func@${{ vars.GCP_PROJECT }}.iam.gserviceaccount.com \
--set-build-env-vars=GOOGLE_BUILDABLE=Mixonomer.Func
shell: bash