-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from equinor/main
Release
- Loading branch information
Showing
28 changed files
with
487 additions
and
830 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,85 +3,91 @@ name: Deploy Database | |
on: | ||
push: | ||
branches: [main, release] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: read | ||
checks: read | ||
contents: read | ||
deployments: read | ||
id-token: write | ||
issues: read | ||
discussions: read | ||
packages: read | ||
pages: read | ||
pull-requests: read | ||
repository-projects: read | ||
security-events: read | ||
statuses: read | ||
contents: read | ||
|
||
jobs: | ||
get-target-configs: | ||
name: Get target configs for branch | ||
outputs: | ||
target_configs: ${{ steps.get-target-configs.outputs.target_configs }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get target configs | ||
id: get-target-configs | ||
run: | | ||
configs=$(ls $GITHUB_WORKSPACE/.github/workflows/config/${GITHUB_REF_NAME} | jq -Rsc '. / "\n" - [""]') | ||
echo "target_configs=${configs}" >> $GITHUB_OUTPUT | ||
deploy-sql-server: | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- get-target-configs | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: ${{ fromJson(needs.get-target-configs.outputs.target_configs) }} | ||
matrix: | ||
target: | ||
- name: "dev" | ||
ref: "refs/heads/main" | ||
client-id: "a23b30b8-3faa-42a1-817e-6cd097a620f1" | ||
server: "sql-radix-vulnerability-scan-dev.database.windows.net" | ||
|
||
- name: "playground" | ||
ref: "refs/heads/release" | ||
client-id: "453fb3de-daaa-43e6-93ef-a470849a2b6b" | ||
server: "sql-radix-vulnerability-scan-playground.database.windows.net" | ||
|
||
- name: "platform" | ||
ref: "refs/heads/release" | ||
client-id: "50e78187-ff60-49c5-bcbe-701bbbf4f5d7" | ||
server: "sql-radix-vulnerability-scan-platform.database.windows.net" | ||
|
||
- name: "c2" | ||
ref: "refs/heads/release" | ||
client-id: "f26240e2-3095-4273-8559-2ca9a121991e" | ||
server: "sql-radix-vulnerability-scan-c2-prod.database.windows.net" | ||
|
||
env: | ||
connection: >- | ||
Server=${{matrix.target.server}}; | ||
Initial Catalog=radix-vulnerability-scan; | ||
Authentication=Active Directory Default; | ||
Encrypt=True; | ||
TrustServerCertificate=False; | ||
Connection Timeout=30; | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Persist environment from ${{ matrix.config }} across steps | ||
run: | | ||
$GITHUB_WORKSPACE/.github/workflows/scripts/persist-env.sh ${{ matrix.config }} | ||
- uses: actions/checkout@v4 | ||
if: matrix.target.ref == github.ref | ||
|
||
- uses: azure/login@v1 | ||
if: matrix.target.ref == github.ref | ||
with: | ||
client-id: ${{matrix.target.client-id}} | ||
tenant-id: "3aa4a235-b6e2-48d5-9195-7fcf05b459b0" | ||
allow-no-subscriptions: true | ||
|
||
- uses: azure/login@v1 | ||
with: | ||
client-id: ${{ env.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ env.AZURE_TENANT_ID }} | ||
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }} | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/predeploy.sql' | ||
|
||
- name: Get DB password from KV | ||
run: | | ||
db_admin_pw=$(az keyvault secret show --id https://${KEY_VAULT_NAME}.vault.azure.net/secrets/${DB_ADMIN_SECRET_NAME} --query value --output tsv) | ||
echo "::add-mask::$db_admin_pw" | ||
echo "DB_ADMIN_PASSWORD=$db_admin_pw" >> $GITHUB_ENV | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/roles.sql' | ||
|
||
- name: Generate random firewall rule name | ||
run: | | ||
fw_rule_name="github-runner-$(uuidgen)" | ||
echo "FIREWALL_RULE_NAME=$fw_rule_name" >> $GITHUB_ENV | ||
- name: Install SqlServer PS module | ||
shell: pwsh | ||
run: | | ||
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted | ||
Install-Module -Name SqlServer | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/types.sql' | ||
|
||
- name: Whitelist Runner IP in firewalls | ||
shell: pwsh | ||
run: | | ||
./.github/workflows/scripts/whitelist-ip.ps1 -FirewallRuleName "${env:FIREWALL_RULE_NAME}" | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/tables.sql' | ||
|
||
- name: Creating DB schema and tables | ||
shell: pwsh | ||
run: | | ||
./.github/workflows/scripts/create-db.ps1 | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/views.sql' | ||
|
||
- name: Blacklist Runner IP in firewalls | ||
shell: pwsh | ||
if: ${{ always() }} | ||
run: | | ||
./.github/workflows/scripts/blacklist-ip.ps1 -FirewallRuleName "${env:FIREWALL_RULE_NAME}" | ||
- uses: azure/[email protected] | ||
if: matrix.target.ref == github.ref | ||
with: | ||
connection-string: ${{env.connection}} | ||
path: './azure-infrastructure/sql-scripts/procedures.sql' |
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
Oops, something went wrong.