Skip to content

Commit

Permalink
Update backport.yml to make it work on commit and pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertBarrow authored Jul 5, 2023
1 parent 418c67b commit 812e9c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/backport/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
MAIN_BRANCH: main
UAT_BRANCH: uat
INTEG_BRANCH: integ
FEATURE_BRANCH_PREFIX: "WI-"
FEATURE_BRANCH_PREFIX: "origin/WI-"

permissions:
contents: write # so it can comment
Expand All @@ -45,9 +45,11 @@ jobs:
# list all branches, filtering for 'WI-', and cutting off remotes/origin/
# then finally substitute newlines for spaces, excluding from the list the source branch which triggered the action
run: |
branches=$(git branch --list --all | grep 'origin/$FEATURE_BRANCH_PREFIX' | cut -c 18- | while read -r line
branches=$(git branch --list --all | grep "$FEATURE_BRANCH_PREFIX" | cut -c 18- | while read -r line
do
if [ "$line" != "$GITHUB_REF_NAME" ]
# in case of commit : if found branch is not the one we are committing on (GITHUB_REF_NAME)
# in case of pull request : if found branch is not the one we are pulling from (GITHUB_HEAD_REF)
if [ "$line" != "$GITHUB_REF_NAME" ] && [ "$line" != "$GITHUB_HEAD_REF" ]
then
echo \"$line\"","
fi
Expand Down Expand Up @@ -93,6 +95,7 @@ jobs:
with:
# Fetch all branches
fetch-depth: 0

- name: Backport from source to target branch(es)
id: pr
uses: cristiammercado/[email protected]
Expand Down

0 comments on commit 812e9c0

Please sign in to comment.