diff --git a/.github/workflows/release-deploy.yml b/.github/workflows/release-deploy.yml new file mode 100644 index 0000000..22815ec --- /dev/null +++ b/.github/workflows/release-deploy.yml @@ -0,0 +1,42 @@ +name: 'Release: Deploy PR' + +on: + pull_request: + branches: [ master ] + types: [ closed ] + +jobs: + release-deploy: + if: github.event.pull_request.merged == true # only run on PR merge + runs-on: ubuntu-latest + steps: + + - name: Configure release + run: | + PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH) + PR_BODY=$(jq -r ".pull_request.body" $GITHUB_EVENT_PATH) + RELEASE_TAG=$(echo "${PR_TITLE}" | grep -oP "(?<=^Release: )v\d+\.\d+\.\d+(-rc\.\d+)?$") + + if [[ "${RELEASE_TAG}" =~ -rc\.[0-9]+$ ]]; then + RELEASE_PRERELEASE=true + else + RELEASE_PRERELEASE=false + fi + + echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV + echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV + echo "RELEASE_PRERELEASE=${RELEASE_PRERELEASE}" >> $GITHUB_ENV + + echo 'PR_BODY<> $GITHUB_ENV + echo "${PR_BODY}" >> $GITHUB_ENV + echo 'END_OF_PR_BODY' >> $GITHUB_ENV + + - name: Create release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.BOT_GITHUB_TOKEN }} + commit: '${{ github.sha }}' + tag: '${{ env.RELEASE_TAG }}' + body: '${{ env.PR_BODY }}' + draft: false + prerelease: ${{ env.RELEASE_PRERELEASE }} diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml new file mode 100644 index 0000000..303087f --- /dev/null +++ b/.github/workflows/release-prepare.yml @@ -0,0 +1,113 @@ +name: 'Release: Prepare PR' + +on: + push: + branches: [ develop ] + +env: + GITHUB_USERNAME: jarvus-bot + GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + RELEASE_BRANCH: master + +jobs: + release-prepare: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # - uses: mxschmitt/action-tmate@v3 + + - name: Create/update pull request + run: | + # get latest release tag + latest_release=$(git describe --tags --abbrev=0 "origin/${RELEASE_BRANCH}") + latest_release_bumped=$(echo $latest_release | awk -F. -v OFS=. '{$NF++;print}') + + + # create or update PR + pr_body="$(cat < /tmp/pr.json + pr_number=$(hub pr list -h develop -f '%I') + echo "Opened PR #${pr_number}" + fi + + + # build changelog + commits=$( + git log \ + --first-parent \ + --reverse \ + --format="%H" \ + "origin/${RELEASE_BRANCH}..develop" + ) + + changelog=() + + while read -r commit; do + subject="$(git show -s --format=%s "${commit}")" + line="" + + if [[ "${subject}" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then + line="$(hub pr show -f '%t [%i] @%au' "${BASH_REMATCH[1]}" || true)" + fi + + if [ -z "${line}" ]; then + author="$(hub api "/repos/${GITHUB_REPOSITORY}/commits/${commit}" -H Accept:application/vnd.github.v3+json | jq -r '.author.login')" + if [ -n "${author}" ]; then + author="@${author}" + else + author="$(git show -s --format=%ae "${commit}")" + fi + + line="${subject} ${author}" + fi + + # move ticket number prefix into to existing square brackets at end + line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*\[([^]]+)\]\s*(\S+)$/\2 [\3, \1] \4/')" + + # move ticket number prefix into to new square brackets at end + line="$(echo "${line}" | perl -pe 's/^([A-Z]+-[0-9]+):?\s*(.*?)\s*(\S+)$/\2 [\1] \3/')" + + # combine doubled square brackets at the end + line="$(echo "${line}" | perl -pe 's/^\s*(.*?)\s*\[([A-Z]+-[0-9]+)\]\s*\[([^]]+)\]\s*(\S+)$/\1 [\3, \2] \4/')" + + changelog+=("- ${line}") + done <<< "${commits}" + + + # create or update comment + comment_body="$(cat <> $GITHUB_ENV + else + echo 'PR title must match format "Release: vX.Y.Z(-rc.#)?"' + exit 1 + fi + + # check that tag doesn't exist + if git ls-remote --exit-code "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "refs/tags/${RELEASE_TAG}"; then + echo "The PR title's version exists already" + exit 1 + fi diff --git a/php-classes/Slate/Network/Site/Connector.php b/php-classes/Slate/Network/Site/Connector.php index 0fdec11..a9a2ab9 100644 --- a/php-classes/Slate/Network/Site/Connector.php +++ b/php-classes/Slate/Network/Site/Connector.php @@ -70,8 +70,7 @@ public static function handleFinishNetworkLoginRequest() return static::throwInvalidRequestError('Redirect URL not set. Please try again or contact an administrator.'); } - $queryParameterGlue = strpos($_REQUEST['redirectUrl'], '?') === -1 ? '?' : '&'; - // TODO: can we always assume query params are being appending to existing, or should we check? + $queryParameterGlue = strpos($_REQUEST['redirectUrl'], '?') === false ? '?' : '&'; header('Location: ' . $_REQUEST['redirectUrl'] . "{$queryParameterGlue}{$queryParameters}"); }