Skip to content

SQL-MI-CICD

SQL-MI-CICD #5

Workflow file for this run

name: SQL-MI-CICD
on:
push:
branches:
- "NA"
workflow_dispatch:
env:
SQL_PROJECT_NAME: DemoSqlProj
SQL_ARTIFACT_NAME: SqlDb
jobs:
build:
name: "Build"
runs-on: self-hosted
env:
DOTNET_INSTALL_DIR: "./.dotnet" # https://github.com/actions/setup-dotnet/issues/327#issuecomment-1278572993
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- name: Build DACPAC
run: dotnet build "data/${{ env.SQL_PROJECT_NAME }}/${{ env.SQL_PROJECT_NAME }}.sqlproj" --configuration Release
- name: Upload artifact
uses: actions/upload-artifact@v3.1.2
with:
name: ${{ env.SQL_ARTIFACT_NAME }}
path: data/${{ env.SQL_PROJECT_NAME }}/bin/Release
deployDev:
needs: build
name: Deploy
runs-on: self-hosted
steps:
- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: "Login via Azure CLI"
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_SP_CREDENTIALS }}
- name: Download Dacpac Artifact
uses: actions/download-artifact@v3.0.2
with:
name: ${{ env.SQL_ARTIFACT_NAME }}
# - name: Azure SQL Deploy
# uses: Azure/sql-action@v2.1
# with:
# connection-string: "Server=tcp:${{ vars.SQL_SERVER_NAME }}.database.windows.net,1433;Initial Catalog=${{ vars.SQL_INITIAL_CATALOG }};Persist Security Info=False;User ID=${{ vars.SQL_ADMIN_USER }};Password=${{ secrets.SQL_ADMIN_PASSWORD }};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
# path: "./${{ inputs.sqlProjectName }}.dacpac"
# action: publish
# arguments: "/p:DropObjectsNotInSource=true"