Skip to content

Commit

Permalink
SRV-796 feat - adding build action
Browse files Browse the repository at this point in the history
  • Loading branch information
nyohasstium committed Sep 20, 2024
1 parent 968f69d commit 09a92ff
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Docker Images"

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]

env:
AWS_REGION: eu-west-1

jobs:
build-image:
name: Build, Tag and Upload
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create dist directory
run: mkdir dist

- name: Compute labels
run: |
TAG_HASH="$(echo $GITHUB_SHA | head -c 8)"
TAG_NAME="$(echo $GITHUB_REF | sed -E -e 's:refs/pull/([0-9]+)/merge:pr.\1:' -e 's:refs/heads/::' -e 's:tag/v?([.0-9]+):v\1:' -e 's:/:.:')"
SUPERSET_REPOSITORY_URI="289222877357.dkr.ecr.eu-west-1.amazonaws.com/webgains/superset"
echo "TAG_HASH=$TAG_HASH" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "SUPERSET_REPOSITORY_URI=$SUPERSET_REPOSITORY_URI" >> $GITHUB_ENV
if [ $TAG_NAME = "main" ]; then echo "LATEST_TAG=$SUPERSET_REPOSITORY_URI:latest" >> $GITHUB_ENV; fi
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_HASH }}
${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_NAME }}
${{ env.LATEST_TAG }}
- name: Create artifact
run: |
printf '[
{"name":"superset","imageUri":"%s"}
]' "$SUPERSET_REPOSITORY_URI:$TAG_HASH" > dist/images.json
- name: Upload artifact to S3
run: |
OBJECT_NAME="superset-$TAG_HASH-$(date +%Y-%m-%d)"
zip -r dist.zip dist
aws s3 cp dist.zip s3://superset-artifacts/$OBJECT_NAME

0 comments on commit 09a92ff

Please sign in to comment.