Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyaven committed Jul 21, 2023
1 parent 4d2f157 commit 7de82fe
Show file tree
Hide file tree
Showing 9 changed files with 2,971 additions and 2,976 deletions.
28 changes: 8 additions & 20 deletions .github/workflows/setup-stackql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,19 @@ jobs:
- name: Use GitHub Provider
run: |
stackql exec -i ./examples/github-example.iql --auth='{ "github": { "type": "basic", "credentialsenvvar": "STACKQL_GITHUB_CREDS" } }'
stackql exec -i ./examples/github-example.iql
env:
STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }}

- name: Prep Google Creds (Windows)
if: ${{ matrix.os == 'windows-latest'}}
run: | ## use the secret to create json file
$GoogleCreds = [System.Environment]::GetEnvironmentVariable("GOOGLE_CREDS_ENV")
$GoogleCredsDecoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($GoogleCreds))
Write-Output $GoogleCredsDecoded | Set-Content sa-key.json
shell: pwsh
env:
GOOGLE_CREDS_ENV: ${{ secrets.GOOGLE_CREDS }}
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}

- name: Prep Google Creds (bash)
if: ${{ matrix.os != 'windows-latest' }}
run: | ## use the secret to create json file
sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json
- name: Use Google Provider
run: |
stackql exec -i ./examples/google-example.iql --auth='{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
stackql exec -i ./examples/google-example.iql
env:
GOOGLE_CREDENTIALS : ${{ secrets.GOOGLE_CREDENTIALS }}

- name: Handle error
if: ${{ matrix.use_wrapper}}
continue-on-error: true
run: | ## use the secret to create json file
stackql exec -i ./examples/github-example.iql --auth="${INVALID_AUTH}"
run: | ## specify a query file that doesnt exist
stackql exec -i ./examples/does-not-exist.iql
62 changes: 26 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,47 @@

# setup-stackql

The `stackql/setup-stackql` action is a JavaScript action that sets up StackQL CLI in your GitHub Actions workflow by:

- Downloading a latest Stackql CLI and adding it to the `PATH`.
- Setup AUTH env var in the Github Action
The `stackql/setup-stackql` action is a JavaScript action that sets up StackQL CLI in your GitHub Actions workflow by downloading a latest Stackql CLI and adding it to the `PATH`.

This action can be run on `ubuntu-latest`, `windows-latest`, and `macos-latest` GitHub Actions runners, and will install and expose the latest version of the `stackql` CLI on the runner environment.

# Usage
[Learn more](https://stackql.io/docs/getting-started/authenticating) about authentication setup when running stackql
## Usage
Authentication to StackQL providers is done via environment variables source from GitHub Actions Secrets. To learn more about authentication, see the setup instructions for your provider or providers at the [StackQL Provider Registry Docs](https://stackql.io/registry).

## 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"
## Examples
The following example demonstrate the use of the `stackql/setup-stackql` action in a GitHub Actions workflow, demonstrating how to use the action to install the `stackql` CLI and then use it to execute a StackQL query.

Check the "Use GitHub Provider" step in [setup-stackql.yml](.github/workflows/setup-stackql.yml) for the working example
### GitHub Example
Check the "Use GitHub Provider" step in [setup-stackql.yml](.github/workflows/setup-stackql.yml) for the working example, for more information on the GitHub provider for StackQL, see the [GitHub Provider Docs](https://registry.stackql.io/github).

```yaml
- name: setup StackQL
uses: stackql/setup-stackql@v1.2.0
with:
use_wrapper: true

### Example
```
- name: Use GitHub Provider
run: |
stackql exec -i ./examples/github-example.iql --auth='{ "github": { "type": "basic", "credentialsenvvar": "STACKQL_GITHUB_CREDS" } }'
stackql exec -i ./examples/github-example.iql
env:
STACKQL_GITHUB_CREDS: ${{ secrets.STACKQL_GITHUB_CREDS }}
```


## json File Auth example

1. Set Auth variable, for example:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
```
{ "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.<name of the secret> }} | base64 -d > sa-key.json`
Check the "Prep Google Creds" step in [setup-stackql.yml](.github/workflows/setup-stackql.yml) for the working example
### Google Example
Check the "Use Google Provider" step in [setup-stackql.yml](.github/workflows/setup-stackql.yml) for the working example, for more information on the Google provider for StackQL, see the [Google Provider Docs](https://registry.stackql.io/google).
### Example
```
- name: Prep Google Creds (bash)
if: ${{ matrix.os != 'windows-latest' }}
run: | ## use the secret to create json file
sudo echo ${{ secrets.GOOGLE_CREDS }} | base64 -d > sa-key.json
```yaml
- name: setup StackQL
uses: stackql/setup-stackql@v1.2.0
with:
use_wrapper: true

- name: Use Google Provider
run: |
stackql exec -i ./examples/google-example.iql --auth='{ "google": { "type": "service_account", "credentialsfilepath": "sa-key.json" }}'
stackql exec -i ./examples/google-example.iql
env:
GOOGLE_CREDENTIALS : ${{ secrets.GOOGLE_CREDENTIALS }}
```
## Inputs
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'StackQL Studios - Setup StackQL'
description: 'Sets up the StackQL CLI in your GitHub Actions workflow.'
author: 'Yuncheng Yang, Jeffery Aven'
author: 'Yuncheng Yang, Jeffrey Aven'
inputs:
use_wrapper:
description: 'Whether or not to install a wrapper to wrap subsequent calls of the `stackql` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.'
Expand Down
Loading

0 comments on commit 7de82fe

Please sign in to comment.