Skip to content

Commit

Permalink
Create project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromav committed Nov 24, 2021
0 parents commit 7c76ba4
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -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"
Empty file added .gitignore
Empty file.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.9-slim

LABEL "maintainer"="Alejandro Martin <hi@alejandromav.com>"
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"]
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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"

```

<br>

## License
The Dockerfile and associated scripts and documentation in this project are released under the [MIT](license).
51 changes: 51 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tinybird
description: Run Tinybird CLI
author: Alejandro Martin <hi@alejandromav.com>

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 }}
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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} $@
21 changes: 21 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 7c76ba4

Please sign in to comment.