Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update sync-release action to run on all release prs #4967

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/sync-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ on:
pull_request:
types:
- closed
branches:
- "release/*"

jobs:
sync:
env:
GH_TOKEN: ${{ secrets.PAT }}
if: "${{ github.event.pull_request.merged && startsWith(github.event.pull_request.base.ref, 'release/') && startsWith(github.event.pull_request.title, 'chore: release') && github.event.pull_request.user.login == 'devops-github-rudderstack' }}"
if: "${{ github.event.pull_request.merged && startsWith(github.event.pull_request.title, 'chore: release ')}}"
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: parse commit
run: |
MERGE_COMMIT_SHA=$(gh pr view ${{ github.event.pull_request.number }} --json mergeCommit -q .mergeCommit.oid)
echo "MERGE_COMMIT_SHA=$MERGE_COMMIT_SHA" >> "$GITHUB_ENV"

- name: parse release tag
run: |
while [ -n $(git describe --contains $MERGE_COMMIT_SHA && echo "ok" || echo "") ]; do
Expand All @@ -32,19 +34,19 @@ jobs:
done;
RELEASE_TAG=$(git describe --contains $MERGE_COMMIT_SHA)
echo "RELEASE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"

- name: create branch
run: |
PR_BRANCH="sync-release-${MERGE_COMMIT_SHA}"
echo "PR_BRANCH=$PR_BRANCH" >> "$GITHUB_ENV"
git checkout $MERGE_COMMIT_SHA -b $PR_BRANCH
git push origin $PR_BRANCH

- name: create pull request for major or minor release
if: ${{ endsWith(env.RELEASE_TAG, '.0') }}
run: |
COMMIT_OVERRIDE=$(git rev-list --reverse --pretty="%s" --cherry-pick --right-only ${PR_BRANCH}...origin/master | grep -v "commit" | grep -v "chore: sync #" || echo "")

echo "# Description" >> body
echo "" >> body
echo "Syncing release ${RELEASE_TAG} to main branch" >> body
Expand All @@ -56,14 +58,14 @@ jobs:
echo "BEGIN_COMMIT_OVERRIDE" >> body
echo "${COMMIT_OVERRIDE}" >> body
echo "END_COMMIT_OVERRIDE" >> body

gh pr create \
--title "chore: sync release ${RELEASE_TAG} to main branch" \
--body "$(cat body)" \
--base master \
--head $PR_BRANCH \
--assignee '${{ github.event.pull_request.merged_by.login }}'

- name: create pull request for patch release
if: ${{ ! endsWith(env.RELEASE_TAG, '.0') }}
run: |
Expand All @@ -78,10 +80,10 @@ jobs:
echo "BEGIN_COMMIT_OVERRIDE" >> body
echo "${COMMIT_OVERRIDE}" >> body
echo "END_COMMIT_OVERRIDE" >> body

gh pr create \
--title "chore: sync release ${RELEASE_TAG} to main branch" \
--body "$(cat body)" \
--base master \
--head $PR_BRANCH \
--assignee '${{ github.event.pull_request.merged_by.login }}'
--assignee '${{ github.event.pull_request.merged_by.login }}'