Skip to content

Merge pull request #107 from milaboratory/merge-2025-09-25 #14

Merge pull request #107 from milaboratory/merge-2025-09-25

Merge pull request #107 from milaboratory/merge-2025-09-25 #14

Workflow file for this run

name: "Create PR for beta branch (v4-beta -> v4)"
on:
push:
paths:
- '.github/workflows/0-merge-beta.yaml'
branches:
- 'v4-beta'
- 'v4'
workflow_dispatch:
inputs:
target_branch:
description: "Target branch to merge into"
required: true
type: choice
options:
- v4
default: "v4"
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Generate Zen Artisan Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GH_ZEN_APP_ID }}
private-key: ${{ secrets.GH_ZEN_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.target_branch || 'v4' }}
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 1000
- name: Get GitHub App User ID
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
echo \
"user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" \
>> "$GITHUB_OUTPUT"
- name: Merge ${{ github.event.inputs.target_branch || 'v4' }}-beta
shell: bash
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
USER_ID: ${{ steps.get-user-id.outputs.user-id }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
TARGET_BRANCH: ${{ github.event.inputs.target_branch || 'v4' }}
run: |
set -x
git config --global user.name "${APP_SLUG}[bot]"
git config --global user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com>"
DATE=$(date +%Y-%m-%d)
MERGE_BRANCH="merge-${DATE}"
git fetch origin
git branch --remotes
if git branch --remotes | grep -q "origin/${MERGE_BRANCH}"; then
git checkout "origin/${MERGE_BRANCH}"
else
git checkout "${TARGET_BRANCH}"
fi
git checkout -b "${MERGE_BRANCH}"
git merge \
--message "Merge ${TARGET_BRANCH}-beta into ${TARGET_BRANCH}" \
"origin/${TARGET_BRANCH}-beta" \
--strategy-option theirs
# Replace all v4-beta with v4 in all action.yaml and all workflows
{
find . -type f -name "action.yaml"
find .github/workflows -type f -name "*.yaml"
} |
xargs -L 1 \
sed -i "s/${TARGET_BRANCH}-beta/${TARGET_BRANCH}/g"
git add .
git commit -m "Merge ${TARGET_BRANCH}-beta into ${TARGET_BRANCH}"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git remote -v
git push origin "${MERGE_BRANCH}"
gh pr create \
--title "Merge ${TARGET_BRANCH}-beta into ${TARGET_BRANCH}" \
--base "${TARGET_BRANCH}" \
--head "${MERGE_BRANCH}"