GitHub - Pipeline Validation Workflow #7
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: GitHub - Pipeline Validation Workflow | |
on: | |
pull_request: | |
branches: | |
- release | |
schedule: | |
- cron: "0 3 * * *" # Runs at 3 AM UTC every night | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
setup-test-environment: | |
name: Spin Up Test SQL Server | |
runs-on: ubuntu-latest | |
env: | |
DB_IMAGE: "mcr.microsoft.com/mssql/server:2019-latest" | |
DB_PORT: "1433" | |
SA_PASSWORD: "Redg@te1" | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Start SQL Server with Access to Backups & Scripts | |
run: | | |
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=${{ env.SA_PASSWORD }}" \ | |
-p ${{ env.DB_PORT }}:1433 -d \ | |
-v ${{ github.workspace }}/backups:/var/opt/mssql/backups \ | |
-v ${{ github.workspace }}/Scripts:/var/opt/mssql/scripts \ | |
${{ env.DB_IMAGE }} | |
- name: Wait for SQL Server to be ready | |
run: sleep 20 # Ensure SQL Server is fully initialized | |
# - name: Install sqlcmd inside the container | |
# run: | | |
# CONTAINER_ID=$(docker ps -q --filter ancestor=${{ env.DB_IMAGE }}) | |
# docker exec -i $CONTAINER_ID /bin/bash -c " | |
# apt-get update && | |
# apt-get install -y curl && | |
# curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && | |
# curl -sSL https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && | |
# apt-get update && | |
# ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev && | |
# echo 'export PATH=\$PATH:/opt/mssql-tools/bin' >> ~/.bashrc | |
# " | |
- name: Execute SQL Script to Create Test Databases | |
run: | | |
CONTAINER_ID=$(docker ps -q --filter ancestor=${{ env.DB_IMAGE }}) | |
docker exec -i $CONTAINER_ID /bin/bash -c " | |
/opt/mssql-tools18/bin/sqlcmd -S 'localhost,${{ env.DB_PORT }}' -U sa -P '${{ env.SA_PASSWORD }}' -i '/var/opt/mssql/scripts/CreateAutoPilotDatabases.sql' -I -C -v TrustServerCertificate=yes | |
" | |
- name: Verify Databases Were Created | |
run: | | |
docker exec -i $(docker ps -q --filter ancestor=${{ env.DB_IMAGE }}) /opt/mssql-tools18/bin/sqlcmd \ | |
-S localhost -U sa -P '${{ env.SA_PASSWORD }}' \ | |
-Q "SELECT name FROM sys.databases" -I -C -v TrustServerCertificate=yes | |
# run-customer-pipeline: | |
# name: Run Customer Pipeline | |
# needs: setup-test-environment | |
# uses: ./.github/workflows/customer-pipeline.yml | |
# with: | |
# db_user: ${{ needs.setup-test-database.outputs.db_user }} | |
# db_password: ${{ needs.setup-test-database.outputs.db_password }} | |
# db_jdbc: ${{ needs.setup-test-database.outputs.db_jdbc }} | |
# secrets: inherit # Inherit existing secrets but allow environment overrides | |