-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (107 loc) · 4.46 KB
/
stackql.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
uses: stackql/[email protected]
with:
query: "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
# uses: stackql/[email protected]
# with:
# query: "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_results_str: '[{"name":"terraform-test-1","name":"terraform-test-2"}]'
# - 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