Skip to content

Commit

Permalink
Update schools experience workflows to use ga wif
Browse files Browse the repository at this point in the history
  • Loading branch information
elaiyganesan committed Feb 18, 2025
1 parent afab2aa commit b873fd7
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 35 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/actions/database-backup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ inputs:
environment:
description: "The name of the environment"
required: true
azure_credentials:
description: "JSON object containing a service principal that can read from Azure Key Vault"
azure-client-id:
description: Managed identity client ID
required: true
azure-subscription-id:
description: Azure subscription ID
required: true
azure-tenant-id:
description: Azure tenant ID
required: true

runs:
Expand All @@ -33,7 +39,9 @@ runs:
- uses: Azure/login@v2
with:
creds: ${{ inputs.azure_credentials }}
client-id: ${{ inputs.azure-client-id }}
tenant-id: ${{ inputs.azure-tenant-id }}
subscription-id: ${{ inputs.azure-subscription-id }}

- name: Fetch slack token
uses: azure/CLI@v2
Expand All @@ -49,7 +57,9 @@ runs:

- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
with:
azure-credentials: ${{ inputs.azure_credentials }}
azure-client-id: ${{ inputs.azure-client-id }}
azure-tenant-id: ${{ inputs.azure-tenant-id }}
azure-subscription-id: ${{ inputs.azure-subscription-id }}

- name: Set environment variables
shell: bash
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ inputs:
sha:
description: Commit sha to be deployed
required: true
azure-credentials:
description: Credentials for azure
azure-client-id:
description: Managed identity client ID
required: true
azure-subscription-id:
description: Azure subscription ID
required: true
azure-tenant-id:
description: Azure tenant ID
required: true
pr:
description: Pull Request Reference
Expand Down Expand Up @@ -73,7 +79,9 @@ runs:

- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
with:
azure-credentials: ${{ inputs.azure-credentials }}
azure-client-id: ${{ inputs.azure-client-id }}
azure-tenant-id: ${{ inputs.azure-tenant-id }}
azure-subscription-id: ${{ inputs.azure-subscription-id }}

- name: Get Short SHA
id: sha
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/build-no-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ on:
schedule:
- cron: '0 12 * * 0'

permissions:
contents: write
packages: write
id-token: write

jobs:
build:
name: Build
environment: review
runs-on: ubuntu-latest

steps:
Expand All @@ -19,7 +25,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.GSE_REPO_AZ_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch synk token from key vault
uses: azure/CLI@v2
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
jobs:
build:
name: Build
environment: review
runs-on: ubuntu-latest
outputs:
DOCKER_IMAGE: ${{ steps.docker.outputs.DOCKER_IMAGE }}
Expand All @@ -37,7 +38,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.GSE_REPO_AZ_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch slack web hook
if: failure() && github.ref == 'refs/heads/master'
Expand Down Expand Up @@ -154,6 +157,7 @@ jobs:

security_tests:
name: Security Tests
environment: review
runs-on: ubuntu-latest
needs: [build]
steps:
Expand All @@ -165,7 +169,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.GSE_REPO_AZ_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -286,6 +292,7 @@ jobs:

sonarcloud:
name: SonarCloud
environment: review
runs-on: ubuntu-latest
needs: [selenium_cucumber_tests, cucumber_tests, security_tests, spec_tests]
steps:
Expand All @@ -298,7 +305,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.GSE_REPO_AZ_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Download Test Artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -393,7 +402,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch SECURE USERNAME
uses: azure/CLI@v2
Expand Down Expand Up @@ -428,7 +439,9 @@ jobs:
with:
environment: ${{matrix.environment}}
sha: ${{ github.sha }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
pr: ${{github.event.number}}
secure-username: ${{ steps.fetch-username.outputs.SECURE_USERNAME}}
secure-password: ${{ steps.fetch-password.outputs.SECURE_PASSWORD}}
Expand Down Expand Up @@ -495,6 +508,7 @@ jobs:

owasp:
name: "OWASP Test"
environment: review
runs-on: ubuntu-latest
needs: [deployments]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -507,7 +521,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.GSE_REPO_AZ_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch SECURE USERNAME
uses: azure/CLI@v2
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/db_backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on:
schedule:
- cron: "0 1 * * *" # 01:00 UTC

permissions:
contents: write
id-token: write

env:
SERVICE_NAME: get-school-experience
SERVICE_SHORT: gse
Expand All @@ -45,13 +49,16 @@ jobs:

- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Set environment variables
run: |
source global_config/${DEPLOY_ENV}.sh
tf_vars_file=${TF_VARS_PATH}/${DEPLOY_ENV}.tfvars.json
echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV
echo "NAMESPACE=$(jq -r '.namespace' ${tf_vars_file})" >> $GITHUB_ENV
echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV
echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV
TODAY=$(date +"%F")
Expand Down Expand Up @@ -82,7 +89,10 @@ jobs:
resource-group: ${{ env.RESOURCE_GROUP_NAME }}
app-name: get-school-experience-${{ env.DEPLOY_ENV }}
cluster: ${{ env.CLUSTER }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
namespace: ${{ env.NAMESPACE }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
backup-file: ${{ env.BACKUP_FILE }}.sql
db-server-name: ${{ inputs.db-server }}
slack-webhook: ${{ steps.key-vault-secrets.outputs.SLACK_WEBHOOK }}
10 changes: 8 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on:

permissions:
id-token: write
contents: write


jobs:
manual:
Expand All @@ -44,7 +46,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch SECURE USERNAME
uses: azure/CLI@v2
Expand Down Expand Up @@ -79,7 +83,9 @@ jobs:
with:
environment: ${{ github.event.inputs.environment }}
sha: ${{ github.event.inputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
pr: ${{ github.event.inputs.pull-request-number }}
secure-username: ${{ steps.fetch-username.outputs.SECURE_USERNAME}}
secure-password: ${{ steps.fetch-password.outputs.SECURE_PASSWORD}}
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
permissions:
id-token: write
pull-requests: write
contents: write

jobs:
destroy:
Expand Down Expand Up @@ -40,11 +41,16 @@ jobs:

- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}


- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: K8 setup for review apps
shell: bash
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
- enable
- disable

permissions:
contents: write
id-token: write

jobs:
set-maintenance-mode:
name: Set maintenance mode
Expand All @@ -29,7 +33,10 @@ jobs:
- name: Enable or disable maintenance mode
uses: DFE-Digital/github-actions/maintenance@master
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS}}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

environment: ${{ inputs.environment }}
mode: ${{ inputs.mode }}
docker-repository: ghcr.io/dfe-digital/schools-experience-maintenance
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:

permissions:
id-token: write
contents: write

jobs:
manual:
Expand All @@ -36,7 +37,9 @@ jobs:

- uses: Azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch SECURE USERNAME
uses: azure/CLI@v2
Expand Down Expand Up @@ -84,7 +87,9 @@ jobs:
with:
environment: ${{ github.event.inputs.environment }}
sha: ${{ steps.tag_id.outputs.release_sha }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
pr: ${{github.event.inputs.pr}}
secure-username: ${{ steps.fetch-username.outputs.SECURE_USERNAME}}
secure-password: ${{ steps.fetch-password.outputs.SECURE_PASSWORD}}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/postgres-ptr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ on:
description: Name of the new database server. Default is <original-server-name>-ptr.
type: string

permissions:
contents: write
id-token: write

env:
SERVICE_SHORT: gse
TF_VARS_PATH: terraform/aks/config
Expand Down Expand Up @@ -67,4 +71,6 @@ jobs:
new-server: ${{ env.NEW_DB_SERVER }}
restore-time: ${{ inputs.restore-time }}
cluster: ${{ env.CLUSTER }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS}}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
10 changes: 9 additions & 1 deletion .github/workflows/postgres-restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on:
type: string
required: false

permissions:
contents: write
id-token: write

env:
SERVICE_NAME: get-school-experience
SERVICE_SHORT: gse
Expand All @@ -47,6 +51,7 @@ jobs:
source global_config/${{ inputs.environment }}.sh
tf_vars_file=${{ env.TF_VARS_PATH }}/${{ inputs.environment }}.tfvars.json
echo "CLUSTER=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV
echo "NAMESPACE=$(jq -r '.namespace' ${tf_vars_file})" >> $GITHUB_ENV
echo "RESOURCE_GROUP_NAME=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-rg" >> $GITHUB_ENV
echo "STORAGE_ACCOUNT_NAME=${AZURE_RESOURCE_PREFIX}${SERVICE_SHORT}dbbkp${CONFIG_SHORT}sa" >> $GITHUB_ENV
echo "DB_SERVER=${AZURE_RESOURCE_PREFIX}-${SERVICE_SHORT}-${CONFIG_SHORT}-pg" >> $GITHUB_ENV
Expand All @@ -66,5 +71,8 @@ jobs:
resource-group: ${{ env.RESOURCE_GROUP_NAME }}
app-name: ${{ env.SERVICE_NAME }}-${{ inputs.environment }}
cluster: ${{ env.CLUSTER }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
namespace: ${{ env.NAMESPACE }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
backup-file: ${{ env.BACKUP_FILE }}
Loading

0 comments on commit b873fd7

Please sign in to comment.