Skip to content

Merge pull request #407 from NHSDigital/release/2024-11-13 #113

Merge pull request #407 from NHSDigital/release/2024-11-13

Merge pull request #407 from NHSDigital/release/2024-11-13 #113

Workflow file for this run

name: "Workflow: Merge to Main"
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
actions: write
jobs:
get-branch-from-workflow-file:
runs-on: [self-hosted, ci]
outputs:
branch_name: ${{ steps.get_branch.outputs.branch_name }}
steps:
- id: get_branch
run: |
workflow_ref=${{ github.workflow_ref }}
branch_name=${workflow_ref#*refs/heads/}
branch_name=${branch_name#*refs/tags/}
echo "branch_name=${branch_name}" >> $GITHUB_OUTPUT
make-tag:
runs-on: [self-hosted, ci]
permissions: write-all
name: Create a tag from main
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Create 'env.tag' from the latest release
run: |
TAG=$(make changelog--get-latest-release)
echo "tag=${TAG}" >> $GITHUB_ENV
- name: Create tag named from 'env.tag'
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.tag }}',
sha: context.sha
})
outputs:
tag: ${{ env.tag }}
set-success:
name: Set Success
needs: [make-tag, get-branch-from-workflow-file]
runs-on: [self-hosted, ci]
steps:
- name: Set success env var
run: echo "success"
outputs:
success: "succeeded"
message-slack:
name: Notify slack of merge to main
needs: [make-tag, get-branch-from-workflow-file, set-success]
runs-on: [self-hosted, ci]
steps:
- name: Catch failed steps
id: catch-failed-step
uses: ./.github/actions/catch-failed-step
- name: Send merge result to slack
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"tag": "${{ needs.make-tag.outputs.tag}}",
"branch": "${{ needs.get-branch-from-workflow-file.outputs.branch_name }}",
"caller": "${{ github.triggering_actor }}",
"result": "${{ needs.set-success.outputs.success && needs.set-success.outputs.success || 'failed' }}",
"result_detail": "${{ needs.set-success.outputs.success && 'None' || steps.catch-failed-step.outputs.failed-step-name }}",
"action_url": "${{ format('{0}/{1}/actions/runs/{2}/attempts/{3}', github.server_url, github.repository, github.run_id, github.run_attempt) }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.MAIN_MERGE_SLACK_HOOK_URL }}