Skip to content

update keboola/kbc-project-backup #125

update keboola/kbc-project-backup

update keboola/kbc-project-backup #125

Workflow file for this run

name: GitHub Actions
on: [ push ]
concurrency: ci-${{ github.ref }} # to avoid tag collisions in the ECR
env:
APP_IMAGE: keboola/project-backup
KBC_DEVELOPERPORTAL_VENDOR: keboola
KBC_DEVELOPERPORTAL_APP: keboola.project-backup
KBC_DEVELOPERPORTAL_USERNAME: keboola+app_project_backup_github_actions
KBC_DEVELOPERPORTAL_PASSWORD: ${{ secrets.KBC_DEVELOPERPORTAL_PASSWORD }}
DOCKERHUB_USER: keboolabot
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# AWS Credentials
TEST_STORAGE_API_URL: https://connection.eu-central-1.keboola.com/
TEST_STORAGE_API_TOKEN: ${{ secrets.TEST_STORAGE_API_TOKEN }}
TEST_AWS_ACCESS_KEY_ID: AKIAQLZBTO5VMQJGVGNK
TEST_AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
TEST_AWS_REGION: eu-central-1
TEST_AWS_S3_BUCKET: ci-app-project-backup-s3filesbucket-7qyiq6iqfrse
# Azure Credentials
TEST_AZURE_STORAGE_API_URL: https://connection.north-europe.azure.keboola.com/
TEST_AZURE_STORAGE_API_TOKEN: ${{ secrets.TEST_AZURE_STORAGE_API_TOKEN }}
TEST_AZURE_ACCOUNT_NAME: ciappprojectbackup
TEST_AZURE_ACCOUNT_KEY: ${{ secrets.TEST_AZURE_ACCOUNT_KEY }}
TEST_AZURE_REGION: eu-west-1
# GCP Credentials
TEST_GCP_STORAGE_API_URL: "https://connection.europe-west3.gcp.keboola.com/"
TEST_GCP_STORAGE_API_TOKEN: ${{ secrets.TEST_GCP_STORAGE_API_TOKEN }}
TEST_GCP_SERVICE_ACCOUNT: ${{ secrets.TEST_GCP_SERVICE_ACCOUNT }}
TEST_GCP_BUCKET: "ci-app-project-backup"
TEST_GCP_REGION: "europe-west3"
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 "::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
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
run: >
docker run --rm
-e TEST_STORAGE_API_URL
-e TEST_STORAGE_API_TOKEN
-e TEST_AWS_ACCESS_KEY_ID
-e TEST_AWS_SECRET_ACCESS_KEY
-e TEST_AWS_REGION
-e TEST_AWS_S3_BUCKET
-e TEST_AZURE_STORAGE_API_URL
-e TEST_AZURE_STORAGE_API_TOKEN
-e TEST_AZURE_ACCOUNT_NAME
-e TEST_AZURE_ACCOUNT_KEY
-e TEST_AZURE_REGION
-e TEST_GCP_STORAGE_API_URL
-e TEST_GCP_STORAGE_API_TOKEN
-e TEST_GCP_BUCKET
-e TEST_GCP_REGION
-e TEST_GCP_SERVICE_ACCOUNT
$APP_IMAGE composer ci
deploy:
needs:
- build
- tests
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 }}