updated workflow #45
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: Demo of stackql GitHub Actions | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
stackql-actions-demo: | |
name: stackql actions demo | |
runs-on: ubuntu-latest | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }} | |
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }} | |
steps: | |
- uses: actions/checkout@v3 | |
name: checkout repo | |
with: | |
fetch-depth: 0 | |
- name: setup StackQL | |
uses: stackql/[email protected] | |
with: | |
use_wrapper: true | |
- name: pull Google docs | |
run: "stackql exec 'REGISTRY PULL google'" | |
- name: dry run StackQL query | |
shell: bash | |
run: | | |
stackql exec \ | |
-i ./stackql/scripts/deploy-instances/deploy-instances.iql \ | |
--iqldata ./stackql/data/vars.jsonnet \ | |
--var GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }} \ | |
--output text -H --dryrun | |
- name: deploy instances using stackql-exec | |
uses: stackql/[email protected] | |
with: | |
query_file_path: './stackql/scripts/deploy-instances/deploy-instances.iql' | |
data_file_path: './stackql/data/vars.jsonnet' | |
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }} | |
- name: check if we have 4 instances using stackql-assert | |
uses: stackql/[email protected] | |
with: | |
test_query_file_path: './stackql/scripts/check-instances/check-instances.iql' | |
data_file_path: './stackql/data/vars.jsonnet' | |
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }} | |
expected_rows: 4 | |
- name: stop running instances using stackql-exec | |
uses: stackql/[email protected] | |
with: | |
query_file_path: './stackql/scripts/stop-instances/stop-instances.iql' | |
- name: "[CLEANUP] delete instances using stackql-exec" | |
uses: stackql/[email protected] | |
with: | |
query_file_path: './stackql/scripts/delete-instances/delete-instances.iql' | |
data_file_path: './stackql/data/vars.jsonnet' | |
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }} | |
stackql-actions-with-terraform-demo: | |
name: stackql actions with terraform demo | |
runs-on: ubuntu-latest | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }} | |
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }} | |
steps: | |
- uses: actions/checkout@v3 | |
name: checkout repo | |
with: | |
fetch-depth: 0 | |
- name: setup StackQL | |
uses: stackql/[email protected] | |
with: | |
use_wrapper: true | |
- name: pull Google docs | |
run: "stackql exec 'REGISTRY PULL google'" | |
- uses: hashicorp/setup-terraform@v2 | |
- name: Terraform Init | |
id: init | |
run: cd terraform; terraform init | |
- name: Terraform Validate | |
env: | |
TF_VAR_google_credentials: ${{ secrets.GOOGLE_CREDENTIALS }} | |
id: validate | |
run: cd terraform; terraform validate -no-color | |
- name: Terraform Plan | |
env: | |
TF_VAR_google_credentials: ${{ secrets.GOOGLE_CREDENTIALS }} | |
id: plan | |
run: cd terraform; terraform plan -no-color -var-file=stackql-demo.tfvars | |
- name: Terraform Apply | |
env: | |
TF_VAR_google_credentials: ${{ secrets.GOOGLE_CREDENTIALS }} | |
id: apply | |
run: cd terraform; terraform apply -no-color -var-file=stackql-demo.tfvars -auto-approve | |
- name: check terraform deployment using stackql-assert - should pass | |
uses: stackql/[email protected] | |
with: | |
test_query_file_path: './stackql/scripts/check-terraform-instances/check-terraform-instances.iql' | |
expected_rows: 3 | |
- name: run a compliance check using stackql-assert - should fail | |
uses: stackql/[email protected] | |
with: | |
test_query_file_path: './stackql/scripts/run-compliance-checks/run-compliance-checks.iql' | |
expected_rows: 0 | |
- name: "[CLEANUP] delete instances and bucket using stackql-exec" | |
if: failure() | |
uses: stackql/[email protected] | |
with: | |
query_file_path: './stackql/scripts/terraform-cleanup/terraform-cleanup.iql' |