forked from SteamWar/SteamWar
Every project gets a checkAffected task that decides whether it has to
be rebuilt. A project is affected when one of these changed:
- its own files, or paths it adds with an affected { } block
- the versions of its resolved dependencies
- a project it depends on
- the root project, which owns the shared build and CI files
Projects list what they ship in a deploy { } block, and can add
afterDeploy commands there. Jars are now byte-reproducible. Only files
whose hash differs from the deployed one are uploaded, and only their
afterDeploy commands are run.
The deploy workflow diffs against the last deployed commit, which is
stored on the server with the dependency versions. PR builds diff
against the merge base. Shared setup steps moved into composite actions
under .gitea/actions.
73 lines
2.2 KiB
YAML
73 lines
2.2 KiB
YAML
name: Pull Request Build
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Setup build
|
|
uses: ./.gitea/actions/setup-build
|
|
with:
|
|
maven-credentials: ${{ secrets.SW_MAVEN_CREDENTIALS }}
|
|
- name: Determine affected projects
|
|
id: affected
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
base_branch="$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")"
|
|
base="$(git merge-base "origin/${base_branch}" HEAD || true)"
|
|
bash .gitea/scripts/affected-projects.sh .ci "$base"
|
|
- name: Build with Gradle
|
|
if: steps.affected.outputs.tasks != ''
|
|
shell: bash
|
|
env:
|
|
TASKS: ${{ steps.affected.outputs.tasks }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
read -ra tasks <<< "$TASKS"
|
|
./gradlew "${tasks[@]}" --no-daemon
|
|
|
|
- name: Merge successful backport PR
|
|
shell: bash
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|
|
BACKPORT_BRANCH_PREFIX: backport/commoncore
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
head_branch="$(jq -r '.pull_request.head.ref // ""' "$GITHUB_EVENT_PATH")"
|
|
base_branch="$(jq -r '.pull_request.base.ref // ""' "$GITHUB_EVENT_PATH")"
|
|
pr_number="$(jq -r '.pull_request.number' "$GITHUB_EVENT_PATH")"
|
|
|
|
if [[ "${head_branch}" != "${BACKPORT_BRANCH_PREFIX}/"* ]]; then
|
|
echo "Not a CommonCore backport PR."
|
|
exit 0
|
|
fi
|
|
|
|
if [[ "${base_branch}" != version/* ]]; then
|
|
echo "Backport PR target is not a version/* branch."
|
|
exit 0
|
|
fi
|
|
|
|
api_url="${GITHUB_API_URL:-${GITHUB_SERVER_URL}/api/v1}"
|
|
|
|
curl -fsS -X POST \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"Do":"merge","delete_branch_after_merge":true}' \
|
|
"${api_url}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/merge"
|