Skip to content

Prepare release 3.6.14 #561

Prepare release 3.6.14

Prepare release 3.6.14 #561

name: Automatic main branch merger
on:
# whenever a pull request is merged into a release branch,
# open a pull request to merge changes down to the main branch
pull_request:
branches:
- '[0-9]+.[0-9]+.x'
# Don't merge 2.8.x into main
- '!2.8.x'
# Don't merge 3.0, 3.1 and 3.2 into main
- '!3.0.x'
- '!3.1.x'
- '!3.2.x'
types:
# means that the PR is closed, we still have to check if it was merged
- closed
env:
# keep this in sync with the automatic-pr-approver workflow
LABEL_TYPE: type:release-branch-port
LABEL_STATUS: status:ready-to-merge
jobs:
update_merge_pr:
runs-on: ubuntu-22.04
# only run this workflow if a pull request has been merged
# don't run this workflow on pull request from forks, permissions will be missing anyway
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories
if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == 'RasaHQ/rasa'
steps:
- name: Checkout git repository 🕝
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
- name: Fetch git tags 🎨
# see https://github.com/actions/checkout/issues/206#issuecomment-617937725
run: git fetch --prune --unshallow --tags
- name: Get branch name ✍️
id: get-branch-name
run: |
GITHUB_BRANCH=${GITHUB_REF/refs\/heads\//}
echo "release_branch=${GITHUB_BRANCH}" >> $GITHUB_OUTPUT
echo "new_branch=merge-${GITHUB_BRANCH}-main-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Get GitHub labels 🏷
id: get-github-labels
run: |
LATEST_RASA_MINOR=$(git tag --list | grep -P '^\d+\.\d+\.\d+$' | tail -n1 | sed -e 's/.\([0-9]\)*$/.0/g')
echo "Latest minor: ${LATEST_RASA_MINOR}"
# bash doesn't support nested variable access
CURRENT_RASA_MINOR=${GITHUB_REF/refs\/heads\//}
CURRENT_RASA_MINOR=${CURRENT_RASA_MINOR/\.x/\.0}
if [[ ${LATEST_RASA_MINOR} == ${CURRENT_RASA_MINOR} ]]
then
echo "labels=${LABEL_TYPE},${LABEL_STATUS}" >> $GITHUB_OUTPUT
else
echo "labels=${LABEL_TYPE}" >> $GITHUB_OUTPUT
fi
- name: Create new branch 🐣
id: create-new-branch
if: always()
uses: peterjgrainger/action-create-branch@64aa569aea81305305c6e92bd236d8c427debff8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ steps.get-branch-name.outputs.new_branch }}
- name: Open pull request ☄️
if: ${{ steps.create-new-branch.conclusion == 'success' }}
uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5
with:
# using this token to make sure it triggers other actions
github_token: ${{ secrets.RASABOT_GITHUB_TOKEN }}
source_branch: ${{ steps.get-branch-name.outputs.new_branch }}
destination_branch: main
pr_title: Merge ${{ steps.get-branch-name.outputs.release_branch }} into main
pr_template: .github/PULL_REQUEST_AUTOMATIC_TEMPLATE.md
pr_label: ${{ steps.get-github-labels.outputs.labels }}
pr_reviewer: ${{ github.event.pull_request.user.login }}
- name: Close outdated release-merge PRs 🧹
id: close-outdated-release-merge-prs
run: |
# fetch all open merge-PRs that have been opened from the current release branch
gh pr list -S "is:open label:${LABEL_TYPE} head:merge-${{ steps.get-branch-name.outputs.release_branch }}-main" > prs.txt
less prs.txt
# delete newly opened PR from the list
awk '!/${{ steps.get-branch-name.outputs.new_branch }}/' prs.txt > temp && mv temp prs.txt
# extract the PR ids
awk '{print $1}' prs.txt > pr_ids.txt
# close all outdated PRs
while read id; do
gh pr close $id -d
done <pr_ids.txt
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Notify Slack on failure 💬
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_INFRASTRUCTURE_SQUAD_MONITORS_WEBHOOK_URL }}
uses: Ilshidur/action-slack@689ad44a9c9092315abd286d0e3a9a74d31ab78a
with:
args: "🚨 There was a problem with porting changes from ${{ env.RELEASE_BRANCH }} to the `main` branch. \
Check out the Github action: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"