forked from singer-io/tap-zoom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build the merge-into-bq job with a dedicated GHA workflow (singer-io#5)
* Build the merge-into-bq job with a dedicated GHA workflow * Remove the merge-into-bq build from the Development workflow * Add label to the merge-into-bq Docker image to cause a rebuild * Hack GHA workflow to push the merge-into-bq job image tagged with `latest` * Publish production docker images to the analytics-warehouse-production project * Change production DWH project and dataset for the masterdata layer
- Loading branch information
Showing
5 changed files
with
117 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: merge-into-bq | ||
on: [push] | ||
|
||
env: | ||
DWH_PROJECT: analytics-warehouse-dev | ||
DOCKER_REGISTRY_PROJECT: analytics-warehouse-dev | ||
|
||
jobs: | ||
merge-into-bq: | ||
runs-on: [ self-hosted, Linux, X64 ] | ||
concurrency: merge-into-bq-${{ github.ref_name }} | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: docker/setup-buildx-action@v2 | ||
- name: 'Login to gcr.io/analytics-warehouse-dev' | ||
if: ${{ github.ref_name != 'master' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: gcr.io | ||
username: _json_key | ||
password: ${{ secrets.DATA_COMPOSER_SA_DEV_KEY }} | ||
- name: 'Login to gcr.io/toptal-hub' | ||
if: ${{ github.ref_name == 'master' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: gcr.io | ||
username: _json_key | ||
password: ${{ secrets.DATA_COMPOSER_SA_PROD_KEY }} | ||
|
||
- name: 'Get base commit SHA' | ||
if: ${{ github.ref_name != 'master' }} | ||
id: base-sha | ||
run: | | ||
git show-ref master -s | ||
echo "::set-output name=value::$(git show-ref master -s)" | ||
- name: 'Get changed files' | ||
id: changed-files | ||
uses: tj-actions/changed-files@v24 | ||
with: | ||
base_sha: ${{ steps.base-sha.outputs.value || github.before }} | ||
files: | | ||
jobs/merge-into-bq/**/* | ||
- name: 'Setup Python' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: 'Get pip cache dir' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
id: pip-cache-dir | ||
run: | | ||
echo "::set-output name=value::$(pip cache dir)" | ||
- name: 'Cache pip' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.pip-cache-dir.outputs.value }} | ||
key: ${{ runner.os }}-poetry-${{ hashFiles('jobs/merge-into-bq/poetry.lock') }} | ||
|
||
- name: 'Setup Poetry' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
uses: Gr1N/setup-poetry@v7 | ||
|
||
- name: 'Poetry install' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
working-directory: jobs/merge-into-bq | ||
run: poetry install | ||
|
||
- name: 'Pytest' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
working-directory: jobs/merge-into-bq | ||
run: poetry run pytest -vv | ||
|
||
- name: 'Get image tag' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
id: image-tag | ||
run: | | ||
if [ '${{ github.ref_name }}' == 'master' ]; then | ||
echo "::set-output name=value::gcr.io/analytics-warehouse-production/data-composer/jobs/merge-into-bq:latest" | ||
else | ||
echo "::set-output name=value::gcr.io/analytics-warehouse-dev/data-composer/jobs/merge-into-bq:${{ github.ref_name }}" | ||
fi | ||
- name: 'Cache Docker layers' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache-staging | ||
key: ${{ runner.os }}-buildx-staging-${{ github.ref_name }} | ||
restore-keys: ${{ runner.os }}-buildx-staging-master | ||
|
||
- name: 'Docker build and push' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: jobs/merge-into-bq | ||
build-contexts: pip_cache=${{ steps.pip-cache-dir.outputs.value }} | ||
push: true | ||
tags: ${{ steps.image-tag.outputs.value }} | ||
cache-from: type=local,src=/tmp/.buildx-cache-staging | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new-staging | ||
|
||
- name: 'Update docker cache' | ||
if: ${{ steps.changed-files.outputs.any_modified == 'true' }} | ||
run: | | ||
rm -rf /tmp/.buildx-cache-staging | ||
mv /tmp/.buildx-cache-new-staging /tmp/.buildx-cache-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
FROM python:3.8 | ||
|
||
LABEL version="1.0.0" | ||
|
||
RUN pip install --upgrade pip && pip install poetry | ||
|
||
WORKDIR /app | ||
|