Skip to content

Merge pull request #52 from keboola/more-logging-ondra #167

Merge pull request #52 from keboola/more-logging-ondra

Merge pull request #52 from keboola/more-logging-ondra #167

Workflow file for this run

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: app-project-migrate
# Developer portal login
KBC_DEVELOPERPORTAL_VENDOR: "keboola"
KBC_DEVELOPERPORTAL_APP: "keboola.app-project-migrate"
KBC_DEVELOPERPORTAL_USERNAME: "keboola+app_project_migrate_github_actions"
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}
# DockerHub login
DOCKERHUB_USER: "keboolabot"
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# Test KBC projects
SOURCE_STORAGE_API_ADMIN_TOKEN: ${{ secrets.SOURCE_STORAGE_API_ADMIN_TOKEN }}
SOURCE_PROJECT_URL: "https://connection.keboola.com/"
DEST_STORAGE_API_TOKEN: ${{ secrets.DEST_STORAGE_API_TOKEN }}
DEST_STORAGE_API_TOKEN_NOT_MASTER: ${{ secrets.DEST_STORAGE_API_TOKEN_NOT_MASTER }}
DEST_PROJECT_URL: "https://connection.europe-west3.gcp.keboola.com/"
DEST_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@v4
-
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 "is_semantic_tag=$IS_SEMANTIC_TAG" >> $GITHUB_OUTPUT
echo "app_image_tag=$TAG" >> $GITHUB_OUTPUT
-
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
steps:
-
name: Check out the repo
uses: actions/checkout@v4
-
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
env:
KBC_URL: ${{env.DEST_PROJECT_URL}}
KBC_TOKEN: ${{env.DEST_STORAGE_API_TOKEN}}
KBC_TOKEN_NOT_MASTER: ${{env.DEST_STORAGE_API_TOKEN_NOT_MASTER}}
SOURCE_STORAGE_API_ADMIN_TOKEN: ${{env.SOURCE_STORAGE_API_ADMIN_TOKEN}}
SOURCE_PROJECT_URL: ${{env.SOURCE_PROJECT_URL}}
run: |
docker run \
-e KBC_URL \
-e KBC_TOKEN \
-e KBC_TOKEN_NOT_MASTER \
-e SOURCE_PROJECT_URL \
-e SOURCE_STORAGE_API_ADMIN_TOKEN \
${{env.APP_IMAGE}} composer ci
tests-in-kbc:
needs: build
runs-on: ubuntu-latest
steps:
-
name: Run KBC test jobs
if: env.DEST_STORAGE_API_TOKEN && env.DEST_PROJECT_CONFIGS
uses: keboola/action-run-configs-parallel@master
with:
token: ${{ env.DEST_STORAGE_API_TOKEN }}
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }}
tag: ${{ needs.build.outputs.app_image_tag }}
configs: ${{ env.DEST_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 }}