Files
wylab-station-14/.github/workflows/labeler-conflict.yml
wylab cbe725b93b
Some checks failed
Build & Test Map Renderer / build (ubuntu-latest) (push) Successful in 3m48s
RGA schema validator / YAML RGA schema validator (push) Successful in 1m0s
RSI Validator / Validate RSIs (push) Failing after 5s
Test Packaging / Test Packaging (push) Successful in 6m18s
YAML Linter / YAML Linter (push) Successful in 3m36s
Build & Test Map Renderer / Build & Test Debug (push) Successful in 1s
Map file schema validator / YAML map schema validator (push) Successful in 10m11s
Build & Test Debug / build (ubuntu-latest) (push) Successful in 36m26s
Build & Test Debug / Build & Test Debug (push) Successful in 3s
Update Contrib and Patreons in credits / get_credits (push) Has been skipped
Build & Publish Docfx / docfx (push) Failing after 24m19s
Publish / build (push) Failing after 3m40s
Publish Public / build (push) Failing after 12m18s
Upstream Sync / check-and-sync (push) Failing after 2m6s
Publish Testing / build (push) Failing after 17m19s
Benchmarks / Run Benchmarks (push) Failing after 3h9m6s
fix: Update secrets config in validation workflows for Gitea (#7)
2025-12-24 04:24:54 +01:00

67 lines
2.5 KiB
YAML

name: Check Merge Conflicts
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- ready_for_review
jobs:
check-conflicts:
if: github.event.pull_request.draft == false && github.actor != 'IanComradeBot'
runs-on: ubuntu-latest
steps:
- name: Check mergeable status and label
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
run: |
PR_INDEX=${{ github.event.pull_request.number }}
REPO_OWNER=${{ github.repository_owner }}
REPO_NAME=${{ github.event.repository.name }}
API_URL="${{ github.server_url }}/api/v1"
# Get PR mergeable status
PR_DATA=$(curl -s -H "Authorization: token $API_TOKEN" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_INDEX")
MERGEABLE=$(echo "$PR_DATA" | jq -r '.mergeable')
echo "PR #$PR_INDEX mergeable status: $MERGEABLE"
LABEL_NAME="S: Merge Conflict"
if [ "$MERGEABLE" = "false" ]; then
echo "PR has merge conflicts, adding label and comment..."
# Add label
curl -s -X POST -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_INDEX/labels" \
-d "{\"labels\":[\"$LABEL_NAME\"]}"
# Add comment
curl -s -X POST -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_INDEX/comments" \
-d '{"body":"This pull request has conflicts, please resolve those before we can evaluate the pull request."}'
echo "Label and comment added."
else
echo "PR is mergeable, no conflicts detected."
# Check if label exists and remove it
LABELS=$(curl -s -H "Authorization: token $API_TOKEN" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_INDEX/labels")
HAS_LABEL=$(echo "$LABELS" | jq -r ".[] | select(.name == \"$LABEL_NAME\") | .id")
if [ -n "$HAS_LABEL" ]; then
echo "Removing stale conflict label..."
# URL-encode the label name (handles spaces, colons, etc.)
LABEL_NAME_ENCODED=$(echo "$LABEL_NAME" | jq -rR @uri)
curl -s -X DELETE -H "Authorization: token $API_TOKEN" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_INDEX/labels/$LABEL_NAME_ENCODED"
echo "Conflict label removed."
fi
fi