forked from SteamWar/SteamWar
Refactor workflows: split pull request build, rename deploy, and remove unused steps
Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
@@ -106,7 +106,6 @@ jobs:
|
|||||||
|
|
||||||
git config --global user.name "SteamWar Backport Bot"
|
git config --global user.name "SteamWar Backport Bot"
|
||||||
git config --global user.email "backport-bot@steamwar.de"
|
git config --global user.email "backport-bot@steamwar.de"
|
||||||
git config --global http.extraHeader "Authorization: token ${GITEA_TOKEN}"
|
|
||||||
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
|
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
|
||||||
|
|
||||||
for commit in "${source_commits[@]}"; do
|
for commit in "${source_commits[@]}"; do
|
||||||
@@ -190,7 +189,7 @@ jobs:
|
|||||||
Source PR: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pulls/${pr_number}
|
Source PR: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pulls/${pr_number}
|
||||||
${source_text}
|
${source_text}
|
||||||
|
|
||||||
This PR will be merged automatically by the Build workflow after a successful build.
|
This PR will be merged automatically by the Pull Request Build workflow after a successful build.
|
||||||
BODY
|
BODY
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
name: Build
|
name: Deploy
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- version/*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -40,7 +44,6 @@ jobs:
|
|||||||
run: ./gradlew build --no-daemon
|
run: ./gradlew build --no-daemon
|
||||||
|
|
||||||
- name: Stage deploy artifacts
|
- name: Stage deploy artifacts
|
||||||
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }}
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -66,7 +69,6 @@ jobs:
|
|||||||
cp "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "deploy/website-api.jar"
|
cp "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "deploy/website-api.jar"
|
||||||
|
|
||||||
- name: Upload deploy artifacts
|
- name: Upload deploy artifacts
|
||||||
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }}
|
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: steamwar-jars
|
name: steamwar-jars
|
||||||
@@ -76,7 +78,6 @@ jobs:
|
|||||||
name: Deploy
|
name: Deploy
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download deploy artifacts
|
- name: Download deploy artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
@@ -129,33 +130,3 @@ jobs:
|
|||||||
|
|
||||||
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH'"
|
ssh -i ~/.ssh/deploy_key -p "$port" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_PATH'"
|
||||||
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
|
scp -i ~/.ssh/deploy_key -P "$port" deploy/* "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_PATH/"
|
||||||
|
|
||||||
merge-backport:
|
|
||||||
name: Merge backport
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
if: ${{ github.event_name == 'pull_request' && 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"
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
name: Pull Request Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
- name: Setup Java 8
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 8
|
||||||
|
- name: Setup Java 11
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 11
|
||||||
|
- name: Setup Java 17
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 17
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 21
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v6
|
||||||
|
- name: Setup Maven Repository
|
||||||
|
env:
|
||||||
|
SW_MAVEN_CREDENTIALS: ${{ secrets.SW_MAVEN_CREDENTIALS }}
|
||||||
|
run: |
|
||||||
|
echo "$SW_MAVEN_CREDENTIALS" > steamwar.properties
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build --no-daemon
|
||||||
Reference in New Issue
Block a user