Skip to content

Commit

Permalink
only run sql updates in prod/c2/playground on push to release
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Feb 7, 2024
1 parent f1ac92f commit 1bcd99d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 105 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,50 @@ jobs:
matrix:
target:
- name: "dev"
if: github.ref == 'refs/heads/master'
ref: "refs/heads/master"
acr-name: "radixdev"
client-id: "1a292b18-2960-49a5-b429-c8a50349b5eb"
subscription-id: "16ede44b-1f74-40a5-b428-46cca9a5741b"

- name: "playground"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
acr-name: "radixdev"
client-id: "1a292b18-2960-49a5-b429-c8a50349b5eb"
subscription-id: "16ede44b-1f74-40a5-b428-46cca9a5741b"

- name: "platform"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
acr-name: "radixprod"
client-id: "d1ee58e8-5896-48d9-a777-5418c3df9a58"
subscription-id: "ded7ca41-37c8-4085-862f-b11d21ab341a"

- name: "c2"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
acr-name: "radixc2prod"
client-id: "d1ee58e8-5896-48d9-a777-5418c3df9a58"
subscription-id: "ded7ca41-37c8-4085-862f-b11d21ab341a"

if: ${{matrix.target.if}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: matrix.target.run == github.ref

- uses: azure/login@v1
if: matrix.target.run == github.ref
with:
client-id: ${{matrix.target.client-id}}
tenant-id: "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
subscription-id: ${{matrix.target.subscription-id}}

- name: Generate image tag
if: matrix.target.run == github.ref
id: tag
run: |
sha=${GITHUB_SHA::8}
ts=$(date +%s)
echo "tag=${GITHUB_REF_NAME}-${sha}-${ts}" >> $GITHUB_OUTPUT
- name: Build image
if: matrix.target.run == github.ref
env:
AZURE_SUBSCRIPTION_ID: ${{matrix.target.subscription-id}}
ACR_NAME: ${{matrix.target.acr-name}}
Expand Down
39 changes: 17 additions & 22 deletions .github/workflows/deploy-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,32 @@ permissions:
contents: read

jobs:
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- id: set-matrix
run: |
branchName=$(echo '${{ github.ref }}' | sed 's,refs/heads/,,g')
matrix=$(jq --arg branchName "$branchName" 'map(
. | select((.runOn==$branchName) or (.runOn=="always"))
)' matrix_includes.json)
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
target:
- name: "dev"
if: github.ref == 'refs/heads/master'
ref: "refs/heads/master"
client-id: "0f26a8a6-3593-4eb3-9d74-b2fb814c6fee"
server: "sql-radix-vulnerability-scan-dev.database.windows.net"

- name: "playground"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
client-id: "8d02c39d-6757-4977-9ad3-017889fe3f45"
server: "sql-radix-vulnerability-scan-playground.database.windows.net"

- name: "platform"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
client-id: "to be decided"
server: "sql-radix-vulnerability-scan-prod.database.windows.net"

- name: "c2"
if: github.ref == 'refs/heads/release'
ref: "refs/heads/release"
client-id: "to be decided"
server: "sql-radix-vulnerability-scan-c2.database.windows.net"

if: ${{matrix.target.if}}
env:
connection: >-
Server=${{matrix.target.server}};
Expand All @@ -62,37 +46,48 @@ jobs:
Connection Timeout=30;
steps:
-

- uses: actions/checkout@v4
if: matrix.target.run == github.ref

- uses: azure/login@v1
if: matrix.target.run == github.ref
with:
client-id: ${{matrix.target.client-id}}
tenant-id: "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
allow-no-subscriptions: true

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/predeploy.sql'

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/roles.sql'

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/types.sql'

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/tables.sql'

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/views.sql'

- uses: azure/sql-action@v2.2.1
if: matrix.target.run == github.ref
with:
connection-string: ${{env.connection}}
path: './azure-infrastructure/sql-scripts/procedures.sql'
34 changes: 0 additions & 34 deletions .github/workflows/targets.json

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/testpr.yml

This file was deleted.

0 comments on commit 1bcd99d

Please sign in to comment.