diff --git a/.github/workflows/docker-push-superset.yaml b/.github/workflows/docker-push-superset.yaml new file mode 100644 index 0000000000000..e9d83bb502d78 --- /dev/null +++ b/.github/workflows/docker-push-superset.yaml @@ -0,0 +1,48 @@ +--- +name: Docker Push - Superset + +on: # yamllint disable-line rule:truthy + push: + branches: + - feat-text-to-sql + +# workflow_run: +# workflows: ["Tag"] +# types: +# - completed + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_and_push_superset_poc: + name: Build & Push Superset Image - POC + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + pull-requests: write +# if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set output + id: vars + run: echo "git_tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT + + # configure iam + - name: Configure IAM Role + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ secrets.POC_SUPERSET_DEPLOY_ARN }} + aws-region: us-east-1 + continue-on-error: false + + - name: Build, Tag, and Push + run: | + export IMAGE_TAG=${{ steps.vars.outputs.git_tag }} + export ENVIRONMENT=poc + ./scrips/docker-build-tag-and-push.sh diff --git a/scripts/docker-build-tag-and-push.sh b/scripts/docker-build-tag-and-push.sh new file mode 100755 index 0000000000000..9da582ed5dafd --- /dev/null +++ b/scripts/docker-build-tag-and-push.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +# optional +: "${AWS_REGION:=us-east-1}" +: "${ENVIRONMENT:=poc}" + +## required +AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) +: "${IMAGE_TAG:-$IMAGE_TAG}" + +ECR_REGISTRY_ENDPOINT="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com" +IMAGE_NAME="$ECR_REGISTRY_ENDPOINT/superset-base" + +echo "Account: $AWS_ACCOUNT_ID" + +printf "\nECR Login...\n" +aws ecr get-login-password \ + --region $AWS_REGION \ + | docker login \ + --username AWS \ + --password-stdin $ECR_REGISTRY_ENDPOINT + +printf "\nBuilding docker images...\n" +docker build -t sourcefuse/superset-base:latest . + +printf "\nTagging image $IMAGE_NAME:$IMAGE_TAG...\n" +docker tag sourcefuse/superset-base:latest $IMAGE_NAME:$IMAGE_TAG + +printf "\nPushing $IMAGE_NAME:$IMAGE_TAG to ECR...\n" +docker push $IMAGE_NAME:$IMAGE_TAG + +echo "::set-output name=image::$IMAGE_NAME:$IMAGE_TAG"