Skip to content

Terraform Batch #135496

Terraform Batch

Terraform Batch #135496

name: Terraform Batch
on: workflow_dispatch
env:
TF_VERSION: 1.1.4
KEYCLOAK_DEV_URL: https://sso-keycloak-1-b861c7-test.apps.silver.devops.gov.bc.ca
KEYCLOAK_TEST_URL: https://sso-keycloak-2-b861c7-test.apps.silver.devops.gov.bc.ca
KEYCLOAK_PROD_URL: https://sso-keycloak-3-b861c7-test.apps.silver.devops.gov.bc.ca
jobs:
terraform:
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
API_URL: ${{ secrets.WEBAPP_API_URL }}
steps:
- uses: hmarr/debug-action@v2
- uses: actions/checkout@v2
- name: Wake Up API
uses: fjogeleit/http-request-action@master
with:
url: ${{ env.API_URL }}/heartbeat
method: GET
customHeaders: '{"Authorization": "${{ secrets.GH_SECRET }}"}'
timeout: '60000'
continue-on-error: true
- name: Fetch Requests Count
id: requests
uses: fjogeleit/http-request-action@master
with:
url: ${{ env.API_URL }}/batch/items/silver
method: GET
customHeaders: '{"Authorization": "${{ secrets.GH_SECRET }}"}'
timeout: '60000'
- name: Get Requests Count
id: count
run: |
count=$(jq length <<< ${{ steps.requests.outputs.response }})
echo "$count"
echo "::set-output name=count::$count"
- name: Pull the main branch again
if: steps.count.outputs.count != '0'
run: |
git pull origin main --rebase
- name: Setup Terraform
if: steps.count.outputs.count != '0'
id: tf
uses: bcgov/sso-requests-actions/actions/[email protected]
with:
context: ./terraform
tf-version: ${{ env.TF_VERSION }}
tf-s3-bucket: xgr00q-dev-keycloak
tf-s3-bucket-key: keycloak/silver
tf-s3-dynamodb-table: xgr00q-dev-state-locking
tf-s3-access-key: ${{ secrets.TF_S3_ACCESS_KEY }}
tf-s3-secret-key: ${{ secrets.TF_S3_SECRET_KEY }}
tf-s3-role-arn: ${{ secrets.TF_S3_ROLE_ARN }}
kc-provider-version: 3.10.0
kc-dev-url: ${{ env.KEYCLOAK_DEV_URL }}
kc-test-url: ${{ env.KEYCLOAK_TEST_URL }}
kc-prod-url: ${{ env.KEYCLOAK_PROD_URL }}
kc-dev-secret: ${{ secrets.KEYCLOAK_DEV_CLIENT_SECRET }}
kc-test-secret: ${{ secrets.KEYCLOAK_TEST_CLIENT_SECRET }}
kc-prod-secret: ${{ secrets.KEYCLOAK_PROD_CLIENT_SECRET }}
apply: true
continue-on-error: true
- name: Setup NPM Packages
if: steps.count.outputs.count != '0'
uses: bcgov/sso-requests-actions/actions/[email protected]
- name: Update Requests Status
if: steps.count.outputs.count != '0'
uses: fjogeleit/http-request-action@master
with:
url: ${{ env.API_URL }}/batch/items
method: PUT
data: "{\"ids\": ${{ steps.requests.outputs.response }}, \"success\": \"${{ steps.tf.outputs.apply != 'failure' }}\"}"
customHeaders: '{"Authorization": "${{ secrets.GH_SECRET }}"}'
timeout: '60000'
- name: Set Failure Code
if: steps.tf.outputs.apply == 'failure'
run: exit 1