Skip to content

Branch Build (1.96) - 18052-workflow-metadata #96

Branch Build (1.96) - 18052-workflow-metadata

Branch Build (1.96) - 18052-workflow-metadata #96

name: Create Branch Build
run-name: "Branch Build (${{ github.run_attempt }}.${{ github.run_number }}) - ${{ github.ref_name }}"
on:
workflow_dispatch:
inputs:
amalgam-build:
description: |
(Optional) amalgam build or version number. Defaults to latest release.
Examples:
'6807310618',
'https://github.com/howsoai/amalgam/actions/runs/6807310618',
'68.0.1'
required: false
type: string
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
set-branch-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-branch-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get previous git tag
id: previous-tag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: 0.0.0
- name: Get next semver from previous tag
id: next-semvers
uses: WyriHaximus/github-action-next-semvers@v1
with:
version: ${{ steps.previous-tag.outputs.tag }}
- name: Set Branch version
id: set-branch-version
run: |
BRANCH_ITERATION=${{ github.run_attempt }}.${{ github.run_number }}
echo "version=$(echo ${{ steps.next-semvers.outputs.patch }}-alpha+BR.${{ github.ref_name }}.${BRANCH_ITERATION})" >> $GITHUB_OUTPUT
construct-payload:
runs-on: ubuntu-latest
outputs:
payload: ${{ steps.construct-payload.outputs.payload }}
steps:
- name: Construct payload
id: construct-payload
run: |
payload="{}"
# Get amalgam version or run ID
if [[ "${{ inputs.amalgam-build }}" =~ runs/([0-9]+) ]]; then
payload=$(echo "$payload" | jq --arg run_id "${BASH_REMATCH[1]}" '. + {"amalgam": $run_id}')
elif [[ -n "${{ inputs.amalgam-build }}" ]]; then
payload=$(echo "$payload" | jq --arg run_id "${{ inputs.amalgam-build }}" '. + {"amalgam": $run_id}')
fi
echo "$payload"
fmtd_payload=$(echo -n "$payload" | tr -d '\n')
echo "payload=$fmtd_payload" >> $GITHUB_OUTPUT
build:
needs: ['set-branch-version', 'construct-payload']
uses: "./.github/workflows/build.yml"
secrets: inherit
with:
version: ${{ needs.set-branch-version.outputs.version }}
payload: ${{ needs.construct-payload.outputs.payload }}
build-type: 'branch'
# This job is here to have only one final step to add for "Status Checks"
# in GitHub, instead of adding every leaf test from 'build'
final-check:
needs: ['build']
if: always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
runs-on: ubuntu-latest
steps:
- run: exit 1