From db7b634c61eb77456faa9951e20b13838f399378 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Tue, 28 Feb 2023 14:52:36 +0100 Subject: [PATCH] Add a `create-branch-if-needed` option --- .github/workflows/reusable-sync.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-sync.yml b/.github/workflows/reusable-sync.yml index 79d825b..a5453d0 100644 --- a/.github/workflows/reusable-sync.yml +++ b/.github/workflows/reusable-sync.yml @@ -80,6 +80,11 @@ on: required: false default: 'lts/*' type: string + create-branch-if-needed: + description: 'Create a branch if one is missing' + required: false + default: true + type: boolean permissions: contents: write @@ -181,10 +186,12 @@ jobs: git config --global user.email "${{ inputs.commit-email }}" git checkout -b ${{ inputs.branch-name }} git add . - if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then - echo "createPR=true" >> $GITHUB_OUTPUT - git commit -m "${{ inputs.commit-message }}" - git push origin ${{ inputs.branch-name }} -fu --no-verify + if ${{ inputs.create-branch-if-needed }} || (git show-ref origin/${{ inputs.branch-name }} -q); then + if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then + echo "createPR=true" >> $GITHUB_OUTPUT + git commit -m "${{ inputs.commit-message }}" + git push origin ${{ inputs.branch-name }} -fu --no-verify + fi fi fi