Skip to content

Merge pull request #218 from nuxeo/dev #16

Merge pull request #218 from nuxeo/dev

Merge pull request #218 from nuxeo/dev #16

name: Hotfix
on:
push:
branches:
- main
# Manually trigger the workflow
workflow_dispatch:
jobs:
get-branch-name:
runs-on: ubuntu-latest
outputs:
last_pr_branch: ${{ steps.get-branch.outputs.last_pr_branch }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags
- name: Authenticate GitHub CLI
run: |
echo "${{ secrets.GIT_TOKEN }}" | gh auth login --with-token
- name: Get the branch name of the last merged PR
id: get-branch
run: |
last_pr_merge_commit=$(git log -1 --pretty=format:"%H")
echo "Last PR merge commit: $last_pr_merge_commit"
merge_message=$(git log -1 --pretty=%B $last_pr_merge_commit)
echo "Merge message: $merge_message"
full_branch_name=$(echo "$merge_message" | grep -oP 'from \K[^/]+/[^\s]+$')
echo "Full branch name: $full_branch_name"
branch_name=$(echo "$full_branch_name" | awk -F'/' '{print $2}')
echo "The branch name is $branch_name & full name is $full_branch_name"
echo "::set-output name=last_pr_branch::$(echo $branch_name | xargs)"
hotfix-merge:
needs: get-branch-name
runs-on: ubuntu-latest
steps:
- name: Checkout Code
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
uses: actions/checkout@v4
- name: Setup Git config
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: git config user.name "nuxeo-webui-jx-bot" && git config user.email "[email protected]"
- name: Authenticate GitHub CLI
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: |
echo "${{ secrets.GIT_TOKEN }}" | gh auth login --with-token
- name: Debug Output
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: |
echo "Branch name: ${{ needs.get-branch-name.outputs.last_pr_branch }}"
- name: Get latest beta tag
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: |
git fetch origin --tags
latest_beta_tag=$(git for-each-ref --sort=-taggerdate --format '%(refname:short)' refs/tags | grep -E '^v23\.[0-9]+\.[0-9]+-beta\.[0-9]+$' | head -n 1 | sed 's/^v//')
echo "Latest beta tag: $latest_beta_tag"
echo "LATEST_BETA_TAG=$latest_beta_tag" >> $GITHUB_ENV
- name: Update beta version
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: |
# Increment beta.x to x+1 while preserving the correct format
BASE_VERSION=$(echo $LATEST_BETA_TAG | sed 's/-beta.*//')
BETA_NUMBER=$(echo $LATEST_BETA_TAG | sed 's/.*-beta.//')
NEW_BETA_NUMBER=$((BETA_NUMBER + 1))
NEW_BETA_TAG="${BASE_VERSION}-beta.${NEW_BETA_NUMBER}"
echo "New beta tag: $NEW_BETA_TAG"
echo "NEW_BETA_TAG=$NEW_BETA_TAG" >> $GITHUB_ENV
- name: Store Beta Release Version as a Secret
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
id: get-hotfix-beta-version
run: |
gh secret set BETA_RELEASE_VERSION --body ${{ env.NEW_BETA_TAG }}
- name: Create Pull Request
if: needs.get-branch-name.outputs.last_pr_branch != 'dev'
run: |
gh pr create --base dev --head main --title "HF: Merge main into dev" --body "### This pull request merges the latest changes from the **main** branch into the **dev** branch."