Skip to content

Build and publish app:kb/fix-health #4

Build and publish app:kb/fix-health

Build and publish app:kb/fix-health #4

name: Build and publish
run-name: Build and publish ${{ inputs.app_name }}:${{ inputs.ref }}
on:
workflow_call:
inputs:
app_name:
description: "name of application folder under infra directory"
required: true
type: string
ref:
description: The branch, tag or SHA to checkout. When checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event. Otherwise, use branch or tag that triggered the workflow run.
required: true
type: string
workflow_dispatch:
inputs:
app_name:
description: "name of application folder under infra directory"
required: true
type: string
ref:
description: The branch, tag or SHA to checkout. When checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event. Otherwise, use branch or tag that triggered the workflow run.
required: true
type: string
jobs:
get-commit-hash:
name: Get commit hash
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.get-commit-hash.outputs.commit_hash }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Get commit hash
id: get-commit-hash
run: |
COMMIT_HASH=$(git rev-parse ${{ inputs.ref }})
echo "Commit hash: $COMMIT_HASH"
echo "commit_hash=$COMMIT_HASH" >> "$GITHUB_OUTPUT"
build-and-publish:
name: Build and publish
runs-on: ubuntu-latest
needs: get-commit-hash
concurrency: ${{ github.workflow }}-${{ needs.get-commit-hash.outputs.commit_hash }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Configure AWS credentials
uses: ./.github/actions/configure-aws-credentials
with:
app_name: ${{ inputs.app_name }}
environment: shared
- name: Check if image is already published
id: check-image-published
run: |
is_image_published=$(./bin/is-image-published "${{ inputs.app_name }}" "${{ inputs.ref }}")
echo "Is image published: $is_image_published"
echo "is_image_published=$is_image_published" >> "$GITHUB_OUTPUT"
- name: Build release
if: steps.check-image-published.outputs.IS_IMAGE_PUBLISHED == 'false'
run: make APP_NAME=${{ inputs.app_name }} release-build
- name: Publish release
if: steps.check-image-published.outputs.IS_IMAGE_PUBLISHED == 'false'
run: make APP_NAME=${{ inputs.app_name }} release-publish