Stackable
Stackable copied to clipboard
Add auto-plugin build in Premium repo
We've added https://github.com/gambitph/Stackable/blob/develop/.github/workflows/plugin-build.yml that builds the plugin per pull request.
We need to do the same with the Premium repo. We have some build code already present in the premium workflow, but the develop
branch is always checked out for the free repo. This works in most cases, but if we have a more complex PR that spans both the free and premium repos, the plugin will not be built correctly.
Unhandled scenario: premium repo branch is fix/1234-some-bug
that also has code adjustments in an identically named free repo branch fix/1234-some-bug
To address this, we need to check the existence of the identical branch name in the free repo, then if that's present, use that, but if not, we fall back to using develop
.
We'll need to replace the current checkout logic in premium to (untested):
- name: Determine free repo branch
id: determine-branches
shell: sh +e {0}
run: |
branch=develop
git ls-remote --exit-code --heads \
"https://github.com/gambitph/Stackable" "$GITHUB_HEAD_REF" \
> /dev/null
if [ $? -eq 0 ]; then
branch="$GITHUB_HEAD_REF"
fi
echo "::set-output name=free_branch::$branch"
done
- uses: actions/checkout@v2
with:
repository: 'gambitph/Stackable'
ref: ${{ steps.determine-branches.outputs.free_branch }}
Thanks to https://github.com/actions/checkout/issues/512#issuecomment-1205349446 for the inspiration.