older schema registry image #21
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
name: Keboola Component Build & Deploy Pipeline | |
on: [ push ] | |
concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR | |
env: | |
# repository variables: | |
KBC_DEVELOPERPORTAL_APP: "kds-team.ex-kafka-consumer" # replace with your component id | |
KBC_DEVELOPERPORTAL_VENDOR: "kds-team" # replace with your vendor | |
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} | |
KBC_DEVELOPERPORTAL_USERNAME: ${{ vars.KBC_DEVELOPERPORTAL_USERNAME }} | |
# repository secrets: | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} # recommended for pushing to ECR | |
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }} | |
# (Optional) Test KBC project: https://connection.keboola.com/admin/projects/0000 | |
KBC_TEST_PROJECT_CONFIGS: "" # space separated list of config ids | |
KBC_STORAGE_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }} # required for running KBC tests | |
jobs: | |
push_event_info: | |
name: Push Event Info | |
runs-on: ubuntu-latest | |
outputs: | |
app_image_tag: ${{ steps.tag.outputs.app_image_tag }} | |
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }} | |
is_default_branch: ${{ steps.default_branch.outputs.is_default_branch }} | |
is_deploy_ready: ${{ steps.deploy_ready.outputs.is_deploy_ready }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Fetch all branches from remote repository | |
run: git fetch --prune --unshallow --tags -f | |
- name: Get current branch name | |
id: current_branch | |
run: | | |
if [[ ${{ github.ref }} != "refs/tags/"* ]]; then | |
branch_name=${{ github.ref_name }} | |
echo "branch_name=$branch_name" | tee -a $GITHUB_OUTPUT | |
else | |
raw=$(git branch -r --contains ${{ github.ref }}) | |
branch="$(echo ${raw//origin\//} | tr -d '\n')" | |
echo "branch_name=$branch" | tee -a $GITHUB_OUTPUT | |
fi | |
- name: Is current branch the default branch | |
id: default_branch | |
run: | | |
echo "default_branch='${{ github.event.repository.default_branch }}'" | |
if [ "${{ github.event.repository.default_branch }}" = "${{ steps.current_branch.outputs.branch_name }}" ]; then | |
echo "is_default_branch=true" | tee -a $GITHUB_OUTPUT | |
else | |
echo "is_default_branch=false" | tee -a $GITHUB_OUTPUT | |
fi | |
- 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 "is_semantic_tag=$IS_SEMANTIC_TAG" | tee -a $GITHUB_OUTPUT | |
echo "app_image_tag=$TAG" | tee -a $GITHUB_OUTPUT | |
- name: Deploy-Ready check | |
id: deploy_ready | |
run: | | |
if [[ "${{ steps.default_branch.outputs.is_default_branch }}" == "true" \ | |
&& "${{ github.ref }}" == refs/tags/* \ | |
&& "${{ steps.tag.outputs.is_semantic_tag }}" == "true" ]]; then | |
echo "is_deploy_ready=true" | tee -a $GITHUB_OUTPUT | |
else | |
echo "is_deploy_ready=false" | tee -a $GITHUB_OUTPUT | |
fi | |
build: | |
name: Docker Image Build | |
runs-on: ubuntu-latest | |
needs: | |
- push_event_info | |
env: | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
tags: ${{ env.KBC_DEVELOPERPORTAL_APP }}:latest | |
outputs: type=docker,dest=/tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.KBC_DEVELOPERPORTAL_APP }} | |
path: /tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar | |
tests: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
needs: | |
- push_event_info | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run Tests | |
run: | | |
docker compose build test | |
docker compose run test | |
tests-kbc: | |
name: Run KBC Tests | |
needs: | |
- push_event_info | |
- build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up environment variables | |
run: | | |
echo "KBC_TEST_PROJECT_CONFIGS=${KBC_TEST_PROJECT_CONFIGS}" >> $GITHUB_ENV | |
echo "KBC_STORAGE_TOKEN=${{ secrets.KBC_STORAGE_TOKEN }}" >> $GITHUB_ENV | |
- name: Run KBC test jobs | |
if: env.KBC_TEST_PROJECT_CONFIGS != '' && env.KBC_STORAGE_TOKEN != '' | |
uses: keboola/action-run-configs-parallel@master | |
with: | |
token: ${{ secrets.KBC_STORAGE_TOKEN }} | |
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }} | |
tag: ${{ needs.push_event_info.outputs.app_image_tag }} | |
configs: ${{ env.KBC_TEST_PROJECT_CONFIGS }} | |
push: | |
name: Docker Image Push | |
runs-on: ubuntu-latest | |
needs: | |
- push_event_info | |
- tests | |
- tests-kbc | |
env: | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.KBC_DEVELOPERPORTAL_APP }} | |
path: /tmp | |
- name: Load Image & Run Tests | |
run: | | |
docker load --input /tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar | |
docker image ls -a | |
- name: Docker login | |
if: env.DOCKERHUB_TOKEN | |
run: docker login --username "${{ env.DOCKERHUB_USER }}" --password "${{ env.DOCKERHUB_TOKEN }}" | |
- 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: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }} | |
tag: ${{ needs.push_event_info.outputs.app_image_tag }} | |
push_latest: ${{ needs.push_event_info.outputs.is_deploy_ready }} | |
source_image: ${{ env.KBC_DEVELOPERPORTAL_APP }} | |
deploy: | |
name: Deploy to KBC | |
env: | |
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }} | |
needs: | |
- push_event_info | |
- build | |
- push | |
if: needs.push_event_info.outputs.is_deploy_ready == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Developer Portal Tag | |
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: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }} | |
tag: ${{ needs.push_event_info.outputs.app_image_tag }} | |
update_developer_portal_properties: | |
name: Developer Portal Properties Update | |
env: | |
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }} | |
needs: | |
- push_event_info | |
- build | |
- push | |
runs-on: ubuntu-latest | |
if: needs.push_event_info.outputs.is_deploy_ready == 'true' | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Update developer portal properties | |
run: | | |
chmod +x scripts/developer_portal/*.sh | |
scripts/developer_portal/update_properties.sh |