diff --git a/.gitea/workflows/backport-commoncore.yml b/.gitea/workflows/backport-commoncore.yml index 8cb081f5..164d28c8 100644 --- a/.gitea/workflows/backport-commoncore.yml +++ b/.gitea/workflows/backport-commoncore.yml @@ -106,7 +106,6 @@ jobs: git config --global user.name "SteamWar Backport Bot" 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/*' for commit in "${source_commits[@]}"; do @@ -190,7 +189,7 @@ jobs: Source PR: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pulls/${pr_number} ${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 )" diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 7496dd9f..09fa125d 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,6 +1,10 @@ -name: Build +name: Deploy -on: [push, pull_request] +on: + push: + branches: + - main + - version/* jobs: build: @@ -40,7 +44,6 @@ jobs: run: ./gradlew build --no-daemon - name: Stage deploy artifacts - if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }} shell: bash run: | set -euo pipefail @@ -66,7 +69,6 @@ jobs: cp "WebsiteBackend/build/libs/WebsiteBackend-all.jar" "deploy/website-api.jar" - name: Upload deploy artifacts - if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }} uses: actions/upload-artifact@v3 with: name: steamwar-jars @@ -76,7 +78,6 @@ jobs: name: Deploy runs-on: ubuntu-latest needs: build - if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'version/')) }} steps: - name: Download deploy artifacts 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'" 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" diff --git a/.gitea/workflows/pull-request-build.yml b/.gitea/workflows/pull-request-build.yml new file mode 100644 index 00000000..e2902e04 --- /dev/null +++ b/.gitea/workflows/pull-request-build.yml @@ -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