KIP-84 fix: reclaim #474
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: Create version branch & PR <working>/* -> version | |
on: | |
push: | |
branches: [ feature/*, bugfix/* ] | |
jobs: | |
auto-pr: | |
name: Automated Master Branch PR | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
pull-requests: write | |
steps: | |
# Work around https://github.com/actions/checkout/issues/760 | |
- name: Add safe.directory | |
run: | | |
git config --global --add safe.directory /github/workspace | |
git config --global --add safe.directory $PWD | |
# ref.: https://github.com/actions/checkout, v3.0.0 | |
- name: Checkout repository | |
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 | |
- name: Extract branch name on pull request | |
shell: bash | |
run: | | |
set -x | |
git branch -r -l | |
echo "(current dir): $PWD" && ls -l ./ | |
chmod -Rv 555 ./scripts | |
RELEASE_VER=$(./scripts/version.sh) && echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV | |
RELEASE_BRANCH="release/$RELEASE_VER" && echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV | |
REPOSITORY_NAME="${{ github.event.repository.name }}" && echo "REPOSITORY_NAME=$REPOSITORY_NAME" >> $GITHUB_ENV | |
echo "SOURCE_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV | |
echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV | |
echo "MASTER_REF=$(git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | head -1 | sed 's/HEAD//')" >> $GITHUB_ENV | |
git ls-remote https://github.com/kiracore/$REPOSITORY_NAME | egrep -q "refs/tags/${RELEASE_VER}$" && echo "RELEASE_EXISTS=true" >> $GITHUB_ENV || echo "RELEASE_EXISTS=false" >> $GITHUB_ENV | |
( git show-branch "origin/$RELEASE_BRANCH" || git show-branch "remotes/origin/$RELEASE_BRANCH" ) && echo "TARGET_BRANCH_EXISTS=true" >> $GITHUB_ENV || echo "TARGET_BRANCH_EXISTS=false" >> $GITHUB_ENV | |
- name: Print debug data before publishing | |
run: | | |
echo "Repository name: ${{ env.REPOSITORY_NAME }}" | |
echo " Source branch: ${{ env.SOURCE_BRANCH }}" | |
echo " Default branch: ${{ env.DEFAULT_BRANCH }}" | |
echo " Master refer.: ${{ env.MASTER_REF }}" | |
echo "Release version: ${{ env.RELEASE_VER }}" | |
echo " Release branch: ${{ env.RELEASE_BRANCH }}" | |
echo " Release exists: ${{ env.RELEASE_EXISTS }}" | |
echo " Event name: ${{ github.event_name }}" | |
echo " Target Exists: ${{ env.TARGET_BRANCH_EXISTS }}" | |
# ref.: https://github.com/peterjgrainger/action-create-branch, v2.2.0 | |
- name: Create version branch from master | |
uses: peterjgrainger/action-create-branch@c2800a3a9edbba2218da6861fa46496cf8f3195a | |
if: | | |
( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) && | |
( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) && | |
( startsWith(env.RELEASE_BRANCH, 'release/v') && contains(env.RELEASE_BRANCH, '.') ) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
branch: ${{ env.RELEASE_BRANCH }} | |
sha: ${{ env.MASTER_REF }} | |
- name: Create PR from feature to version branch | |
# ref. repo-sync/pull-request is broken, using cea2aj/pull-request instead | |
uses: cea2aj/pull-request@84eb0c3478f13651e5649367941b867ca02d7926 | |
if: | | |
( env.TARGET_BRANCH_EXISTS == false || env.TARGET_BRANCH_EXISTS == 'false' ) && | |
( env.RELEASE_EXISTS == false || env.RELEASE_EXISTS == 'false' ) && | |
( startsWith(env.RELEASE_BRANCH, 'release/v') && contains(env.RELEASE_BRANCH, '.') ) | |
with: | |
github_token: ${{ secrets.REPO_ACCESS }} | |
source_branch: ${{ env.SOURCE_BRANCH }} | |
destination_branch: ${{ env.RELEASE_BRANCH}} | |
pr_title: "${{ env.SOURCE_BRANCH }} -> ${{ env.RELEASE_BRANCH }}" | |
pr_label: "kira-automation" | |
pr_allow_empty: true |