Skip to content

build-reports-image #33

build-reports-image

build-reports-image #33

name: Build reports image
on:
workflow_dispatch:
inputs:
branch:
default: 'trunk'
description: 'Branch to build'
required: true
commit_sha:
description: 'Commit sha to build'
required: true
repository_dispatch:
types:
- build-reports-image
concurrency:
group: reports-${{ github.ref }}
cancel-in-progress: true
jobs:
prep:
runs-on: ubuntu-latest
outputs:
client: ${{ steps.prep.outputs.client }}
branch: ${{ steps.prep.outputs.branch}}
commit_sha: ${{ steps.prep.outputs.commit_sha }}
steps:
- name: Set variables from workflow dispatch
id: prep
run: |
if [[ "${{github.event_name}}" == "repository_dispatch" ]]; then
echo ::set-output name=client::${{ github.event.client_payload.client }}
echo ::set-output name=branch::${{ github.event.client_payload.branch }}
echo ::set-output name=commit_sha::${{ github.event.client_payload.commit_sha }}
else
echo ::set-output name=client::${{ github.event.inputs.client }}
echo ::set-output name=branch::${{ github.event.inputs.branch }}
echo ::set-output name=commit_sha::${{ github.event.inputs.commit_sha }}
fi
build-and-upload-image:
runs-on: ubuntu-latest
needs: [prep]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.prep.outputs.branch }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
# Key is named differently to avoid collision
key: ${{ runner.os }}-multi-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-multi-buildx
# Provide credentials for AWS
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# Must use docker login in order to specify public registry
- name: Login to Public ECR
uses: docker/login-action@v1
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build reports Image
uses: docker/build-push-action@v2
with:
context: .
push: true
builder: ${{ steps.buildx.outputs.name }}
file: .docker/production/Dockerfile.gha
target: reports
tags: public.ecr.aws/ideacrew/gluedb:${{ needs.prep.outputs.client }}-reports
build-args: |
CLIENT=${{ needs.prep.outputs.client }}
COMMIT_SHA=${{ needs.prep.outputs.commit_sha }}
BRANCH=${{ needs.prep.outputs.branch }}