Skip to content

Commit

Permalink
Merge pull request #28 from keboola/ondra-migrate-to-gha
Browse files Browse the repository at this point in the history
Migrate to github actions
  • Loading branch information
ondrajodas authored Nov 2, 2021
2 parents 8893b18 + 6004ad2 commit 262e34f
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 67 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: GitHub Actions
on: [ push ]
concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR
env:
# Name of the image in the ECR
APP_IMAGE: keboola-wr-looker-v2

# Developer portal login
KBC_DEVELOPERPORTAL_VENDOR: "keboola"
KBC_DEVELOPERPORTAL_APP: "keboola.wr-looker-v2"
KBC_DEVELOPERPORTAL_USERNAME: "keboola+wr_looker_v2_gha"
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}

KBC_URL: "https://connection.keboola.com/"
KBC_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }}
SNOWFLAKE_BACKEND_CONFIG_ID: "636916992"
SNOWFLAKE_BACKEND_DB_PASSWORD: ${{ secrets.SNOWFLAKE_BACKEND_DB_PASSWORD }}
BIGQUERY_BACKEND_CONFIG_ID: "638537315"
BIGQUERY_BACKEND_PRIVATE_KEY: ${{ secrets.BIGQUERY_BACKEND_PRIVATE_KEY }}

# DockerHub login
DOCKERHUB_USER: "keboolabot"
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

# Test KBC project
KBC_STORAGE_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }}
KBC_TEST_PROJECT_URL: "https://connection.keboola.com/admin/projects/8296"
#KBC_TEST_PROJECT_CONFIGS: "638537315 636916992" # space separated list
KBC_TEST_PROJECT_CONFIGS: "" # space separated list
jobs:
build:
runs-on: ubuntu-latest
outputs:
app_image_tag: ${{ steps.tag.outputs.app_image_tag }}
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }}
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Print Docker version
run: docker -v
-
name: Docker login
if: env.DOCKERHUB_TOKEN
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
-
name: Build image
run: docker build -t $APP_IMAGE .
-
name: Set image tag
id: tag
run: |
TAG="${GITHUB_REF##*/}"
IS_SEMANTIC_TAG=$(echo "$TAG" | grep -q '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo true || echo false)
echo "Tag = '$TAG', is semantic tag = '$IS_SEMANTIC_TAG'"
echo "::set-output name=app_image_tag::$TAG"
echo "::set-output name=is_semantic_tag::$IS_SEMANTIC_TAG"
-
name: Push image to ECR
uses: keboola/action-push-to-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ steps.tag.outputs.app_image_tag }}
push_latest: ${{ steps.tag.outputs.is_semantic_tag }}
source_image: ${{ env.APP_IMAGE}}

tests:
needs: build
runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix: ...
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
-
name: Run tests
run: docker run
-e KBC_URL
-e KBC_TOKEN
-e SNOWFLAKE_BACKEND_CONFIG_ID
-e SNOWFLAKE_BACKEND_DB_PASSWORD
-e BIGQUERY_BACKEND_CONFIG_ID
-e BIGQUERY_BACKEND_PRIVATE_KEY
$APP_IMAGE
composer ci

tests-in-kbc:
needs: build
runs-on: ubuntu-latest
steps:
-
name: Run KBC test jobs
if: env.KBC_STORAGE_TOKEN && env.KBC_TEST_PROJECT_CONFIGS
uses: keboola/action-run-configs-parallel@master
with:
token: ${{ env.KBC_STORAGE_TOKEN }}
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }}
tag: ${{ needs.build.outputs.app_image_tag }}
configs: ${{ env.KBC_TEST_PROJECT_CONFIGS }}

deploy:
needs:
- build
- tests
- tests-in-kbc
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && needs.build.outputs.is_semantic_tag == 'true'
steps:
-
name: Set tag in the Deloper Portal
uses: keboola/action-set-tag-developer-portal@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

34 changes: 0 additions & 34 deletions deploy.sh

This file was deleted.

0 comments on commit 262e34f

Please sign in to comment.