I want to trigger a GitHub Actions workflow when a release/vX.Y.Z format of PR gets merged into the main branch.
I want the version number from this head branch i.e. "vX.Y.Z" so that I can create a release and tag it accordingly.
name: Auto PR Action
on:
pull_request:
branches:
- main
types: [closed]
jobs:
build:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
- name: Extract version number
run: |
echo "${{ github.event.pull_request.base_ref }}"
# Extract version number from the Release branch format: release/v1.2.3
# E.g: release/v1.2.3 | sed 's/.*\///' will give us v1.2.3
echo "${{ GET_THE_RELEASE_BRANCH_NAME }}" | sed 's/.*\///' >> $RELEASE_VERSION
- name: Create Release
id: create_release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create $RELEASE_VERSION --generate-notes --latest --verify-tag
I always get the information about the base branch, i.e. main, but no info about the head branch.
How can we achieve this?