diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100755 index 0000000..9eecafd --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,37 @@ +# This is a comment. +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @alejandromav + +# Order is important; the last matching pattern takes the most +# precedence. When someone opens a pull request that only +# modifies JS files, only @js-owner and not the global +# owner(s) will be requested for a review. +# *.js @js-owner + +# You can also use email addresses if you prefer. They'll be +# used to look up users just like we do for commit author +# emails. +# *.go docs@example.com + +# In this example, @doctocat owns any files in the build/logs +# directory at the root of the repository and any of its +# subdirectories. +# /build/logs/ @doctocat + +# The `docs/*` pattern will match files like +# `docs/getting-started.md` but not further nested files like +# `docs/build-app/troubleshooting.md`. +# docs/* docs@example.com + +# In this example, @octocat owns any file in an apps directory +# anywhere in your repository. +# apps/ @octocat + +# In this example, @doctocat owns any file in the `/docs` +# directory in the root of your repository. +# /docs/ @doctocat diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml new file mode 100755 index 0000000..ba2a3d8 --- /dev/null +++ b/.github/workflows/ci-workflow.yml @@ -0,0 +1,19 @@ +name: CI + +on: [ push ] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Test CLI works + steps: + # To use this repository's private action, + # you must check out the repository + - name: Checkout + uses: actions/checkout@v2 + - name: Test Tinybird CLI, should prompt help + uses: ./ # Uses an action in the root directory + id: tinybird-cli + with: + token: ${{ secrets.TINYBIRD_TOKEN }} + args: "--debug push" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..574e8d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9-slim + +LABEL "maintainer"="Alejandro Martin " +LABEL "repository"="https://github.com/alejandromav/tinybird-action" +LABEL "homepage"="https://github.com/alejandromav/tinybird-action" + +LABEL "com.github.actions.name"="tinybird" +LABEL "com.github.actions.description"="Run Tinybird CLI" +LABEL "com.github.actions.icon"="activity" +LABEL "com.github.actions.color"="gray-dark" + +RUN pip install tinybird-cli + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..d18ee55 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Tinybird GitHub Action +This action allows you to run [Tinybird CLI](https://docs.tinybird.co/cli.html) on your project. + +## Usage +To use the action simply create an `*.yml`file in the `.github/workflows/` directory. + +For example: + +```yaml +name: Push to Tinybird # feel free to pick your own name + +on: + push: + branches: + - master + - main + - stable + - release/v* + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + # Important: This sets up your GITHUB_WORKSPACE environment variable + - uses: actions/checkout@v2 + + - name: Lint Ansible Playbook + # replace "master" with any valid ref + uses: alejandromav/tinybird-action@master + with: + # [required] + # Tinybird admin token. Please, use Github secrets (https://docs.github.com/en/actions/security-guides/encrypted-secrets) + token: ${{ secrets.TINYBIRD_TOKEN }} + # [optional] + # Arguments to be passed to the Tinybird CLI + args: "push --push-deps --debug" + +``` + +
+ +## License +The Dockerfile and associated scripts and documentation in this project are released under the [MIT](license). diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..d5164f5 --- /dev/null +++ b/action.yml @@ -0,0 +1,51 @@ +name: Tinybird +description: Run Tinybird CLI +author: Alejandro Martin + +inputs: + args: + description: | + Usage: tb [OPTIONS] COMMAND [ARGS]... + + Options: + --debug / --no-debug Print internal representation + --token TEXT Use auth token, defaults to TB_TOKEN envvar, + then to the .tinyb file + --host TEXT Use custom host, defaults to TB_HOST envvar, + then to https://api.tinybird.co + --version-warning / --no-version-warning + Don't print version warning message if + there's a new available version. You can use + TB_VERSION_WARNING envar + --version Show the version and exit. + --help Show this message and exit. + + Commands: + auth Configure auth + check Check file syntax + connection Connection commands + datasource Data sources commands + dependencies Print all data sources dependencies + drop-prefix Drop all the resources inside a project with prefix. This + command is dangerous because it removes everything, use with + care + init Initialize folder layout + job Jobs commands + pipe Pipes commands + pull Retrieve latest versions for project files from Tinybird + push Push files to Tinybird + sql Run SQL query over data sources and pipes + workspace Workspace commands + required: false + + token: + description: Tinybird admin token + required: true + +runs: + using: docker + image: Dockerfile + args: + - ${{ inputs.args }} + env: + TOKEN: ${{ inputs.token }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..858dea6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh -l + +: "${TOKEN?Tinybird token not found, please check README.md.}" +: "${GITHUB_WORKSPACE?GITHUB_WORKSPACE has to be set. Did you use the actions/checkout action?}" + +>&2 echo "\nRunning Tinybird CLI...\n" +echo "tb --token ${TOKEN} $@" +tb --token ${TOKEN} $@ diff --git a/license b/license new file mode 100644 index 0000000..e774a28 --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Alejandro Martin, hi@alejandromav.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file