forked from SteamWar/SteamWar
Add merge-backport workflow to automate PR backports after successful builds
Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
@@ -39,3 +39,33 @@ jobs:
|
|||||||
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build --no-daemon
|
run: ./gradlew build --no-daemon
|
||||||
|
|
||||||
|
merge-backport:
|
||||||
|
name: Merge backport
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: ${{ startsWith(github.event.pull_request.base.ref, 'version/') && startsWith(github.event.pull_request.head.ref, 'backport/pr-') }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- name: Merge successful backport PR
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
pr_number="$(jq -r '.number' "$GITHUB_EVENT_PATH")"
|
||||||
|
target_branch="$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")"
|
||||||
|
payload="$(jq -n \
|
||||||
|
--arg title "Merge backport #${pr_number} into ${target_branch}" \
|
||||||
|
'{Do: "merge", MergeTitleField: $title, MergeMessageField: "Automatic CommonCore backport after successful build.", delete_branch_after_merge: true}')"
|
||||||
|
|
||||||
|
curl --fail --silent --show-error \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
--data "$payload" \
|
||||||
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/merge"
|
||||||
|
|||||||
Reference in New Issue
Block a user