diff --git a/.github/workflows/example-workflows.yml b/.github/workflows/example-workflows.yml new file mode 100644 index 0000000..6b79980 --- /dev/null +++ b/.github/workflows/example-workflows.yml @@ -0,0 +1,43 @@ +name: 'Setup StackQL' + +on: + push: + branches: + - main + - 'develop-**' + pull_request: + +defaults: + run: + shell: bash + +jobs: + stackql-versions: + name: 'Stackql Versions' + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup stackql + uses: ./ + + + - name: Validate Stackql Version + run: | + stackql --version + + - name: Use GitHub Provider + run: | + stackql exec -i ./examples/github-example.iql --auth="${AUTH}" + env: + AUTH: ${{ vars.AUTH }} ##'{ "github": { "type": "basic", "credentialsenvvar": "STACKQL_GITHUB_CREDS" } }' + STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }} + + - name: use Google Provider + run: | ## use the secret to create json file + sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json + stackql exec -i ./examples/google-example.iql --auth="${AUTH}" + env: + AUTH: ${{ vars.AUTH }} ## '{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}' diff --git a/.github/workflows/set-up-stackql.yml b/.github/workflows/set-up-stackql.yml deleted file mode 100644 index aa84b6b..0000000 --- a/.github/workflows/set-up-stackql.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: 'Setup StackQL' - -on: - push: - branches: - - main - - 'develop-**' - pull_request: - -defaults: - run: - shell: bash - -jobs: - stackql-versions: - name: 'Stackql Versions' - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup stackql - uses: ./ - - - - name: Validate Stackql Version - run: | - stackql --version - - - name: Use GitHub Provider - run: | - stackql exec -i ./examples/get-github-commits.iql --auth="${AUTH}" - env: - AUTH: ${{ vars.AUTH }} - STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }} \ No newline at end of file diff --git a/README.md b/README.md index d760c4a..4b72d3a 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,26 @@ The `stackql/setup-stackql` action is a JavaScript action that sets up Terraform - Downloading a latest Stackql CLI and adding it to the `PATH`. - Setup AUTH env var in the Github Action -## Auth object string -Example +# Auth +[Learn more](https://stackql.io/docs/getting-started/authenticating) about authentication setup when running stackql + +### Basic Example +1. Set Auth variable, for example: +``` +{ "github": { "type": "basic", "credentialsenvvar": "STACKQL_GITHUB_CREDS" } } +``` +2. create the github token as a secret +3. In the execution step, pass the secret as environment variable with name "STACKQL_GITHUB_CREDS" + +Check the "Use GitHub Provider" step in `.github/workflows/example-workflows.yml` for the working example + +### json File Auth example + +1. Set Auth variable, for example: ``` -{ - "google": { "credentialsfilepath": "creds/stackql-demo.json", "type": "service_account" }, - "okta": { "credentialsenvvar": "OKTA_SECRET_KEY", "type": "api_key", credentials: '' } -} +{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }} ``` +2. encode the key json file into base64 string +3. in execution step, run `sudo echo ${{ secrets. }} | base64 -d > sa-key.json` +Check the "Use Google Provider" step in `.github/workflows/example-workflows.yml` for the working example \ No newline at end of file diff --git a/examples/get-github-commits.iql b/examples/github-example.iql similarity index 100% rename from examples/get-github-commits.iql rename to examples/github-example.iql diff --git a/examples/google-example.iql b/examples/google-example.iql new file mode 100644 index 0000000..ce2eab9 --- /dev/null +++ b/examples/google-example.iql @@ -0,0 +1,4 @@ +REGISTRY PULL google v23.01.00116; +SELECT name, status +FROM google.compute.instances +WHERE project = 'stackql-demo' AND zone = 'australia-southeast1-a'; \ No newline at end of file