Skip to content

SRV-948 fix - adding permissions to github workflow (#50) #87

SRV-948 fix - adding permissions to github workflow (#50)

SRV-948 fix - adding permissions to github workflow (#50) #87

Workflow file for this run

name: "Docker Images"
on:
push:
branches:
- master
workflow_call:
outputs:
tag_hash:
description: "The commit hash used to tag the Docker image"
value: ${{ jobs.build-image.outputs.tag_hash }}
env:
AWS_REGION: eu-west-1
jobs:
build-image:
name: Build, Tag and Upload
runs-on: ubuntu-latest
permissions:
checks: write
actions: write
contents: write
packages: read
issues: read
pull-requests: write
id-token: write
env:
SUPERSET_REPOSITORY_URI: "289222877357.dkr.ecr.eu-west-1.amazonaws.com/webgains/superset"
BUILD_ROLE_ARN: arn:aws:iam::289222877357:role/github-superset-access
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create dist directory
run: mkdir dist
- name: Compute labels
id: 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:/:.:')"
echo "TAG_HASH=$TAG_HASH" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
if [ $TAG_NAME = "main" ]; then echo "LATEST_TAG=$SUPERSET_REPOSITORY_URI:latest" >> $GITHUB_ENV; fi
echo "tag_hash=$TAG_HASH" >> $GITHUB_OUTPUT
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ env.BUILD_ROLE_ARN }}
role-session-name: build-${{ github.run_id }}
- 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 }}
target: webgains
outputs:
tag_hash: ${{ steps.compute_labels.outputs.tag_hash }}