Merge Release Branch and Tag #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Merge Release Branch and Tag | |
on: | |
workflow_run: | |
workflows: [Test desertislandutils] | |
types: [completed] | |
branches: | |
- 'release/**' | |
env: | |
RELEASE_BRANCH: ${{ github.event.workflow_run.head_branch }} | |
jobs: | |
merge-and-tag: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Show workspace contexts | |
run: | | |
echo "head branch of trigger run: ${{ github.event.workflow_run.head_branch }}" | |
echo "shell RELEASE_BRANCH: $RELEASE_BRANCH" | |
- name: 'Checkout the whole repo' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Generate tag name >> GITHUB_ENV | |
run: | | |
echo "release_tag_name=$(echo "$RELEASE_BRANCH" \ | |
| sed --regexp-extended \ | |
's/.*release.*([0-9].[0-9].[0-9])/v\1/g')" >> $GITHUB_ENV | |
- name: Configure repo for autobot merge commit | |
run: | | |
git config user.name gha-bot | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git config --list | |
git checkout "$RELEASE_BRANCH" | |
git branch --list | |
git log --graph -n10 --pretty=format:'%h %as %cn %x09%s %d' | |
- name: Merge back to dev | |
run: | | |
git checkout dev | |
git merge --no-ff main | |
git push origin dev | |
- name: Merge the latest release commit | |
run: | | |
echo "release_tag_name: $release_tag_name" | |
echo "next step: git merge --no-ff $RELEASE_BRANCH" | |
# required to initialise branch visibility | |
git checkout "$RELEASE_BRANCH" | |
git checkout main | |
git merge --no-ff "$RELEASE_BRANCH" | |
git push origin main | |
git tag --annotate "$release_tag_name" -m "release $release_tag_name" | |
git push origin "$release_tag_name" | |
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++" | |
git log --graph --all -n10 --pretty=format:'%h %as %cn %x09%s %d' | |
- name: | |
run: | | |
echo "YOU CAN DELETE RELEASE BRANCH: $RELEASE_BRANCH" | |
echo "RELEASE AND DEV MERGED" | |
on-failure: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- run: echo 'STOP THE PRESSES NO MERGE. MUST SEND A MESSAGE' |