mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Add workflows for PR checks
This commit is contained in:
31
.github/workflows/check_gradle_all.yaml
vendored
Normal file
31
.github/workflows/check_gradle_all.yaml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Check all projects
|
||||
name: 🐘 Gradle | Check All
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
build_gradle:
|
||||
name: 🐘 Build Gradle
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 🚩 Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: ❓ Ensure Wrapper Permissions
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: ☕ Setup Java
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: 🐘 Gradle Check
|
||||
uses: gradle/gradle-build-action@v2
|
||||
env:
|
||||
CI: true
|
||||
with:
|
||||
arguments: "check --scan"
|
||||
77
.github/workflows/comment_on_pr.yaml
vendored
Normal file
77
.github/workflows/comment_on_pr.yaml
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
name: 💬 Comment on PR
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
comment-on-pr:
|
||||
name: 💬 Comment on PR
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Get Artifact and Pull request info
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
OWNER: ${{ github.repository_owner }}
|
||||
REPO: ${{ github.event.repository.name }}
|
||||
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
|
||||
run: |
|
||||
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
|
||||
echo "Previous Job ID: $PREVIOUS_JOB_ID"
|
||||
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"
|
||||
|
||||
SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
|
||||
echo "Previous Suite ID: $SUITE_ID"
|
||||
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"
|
||||
|
||||
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
|
||||
--jq ".artifacts.[] |
|
||||
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
|
||||
select(.expired==false) |
|
||||
.id")
|
||||
|
||||
echo "Artifact ID: $ARTIFACT_ID"
|
||||
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"
|
||||
|
||||
PR_NUMBER=$(jq -r '.pull_requests[0].number' \
|
||||
<<< "$WORKFLOW_RUN_EVENT_OBJ")
|
||||
|
||||
echo "Pull request Number: $PR_NUMBER"
|
||||
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
|
||||
|
||||
HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
|
||||
<<< "$WORKFLOW_RUN_EVENT_OBJ")
|
||||
|
||||
echo "Head SHA: $HEAD_SHA"
|
||||
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Delete old comments
|
||||
uses: izhangzhihao/delete-comment@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
delete_user_name: github-actions[bot]
|
||||
issue_number: ${{ env.PR_NUMBER }}
|
||||
|
||||
- name: Update Comment
|
||||
env:
|
||||
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
|
||||
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
|
||||
HEAD_SHA: "${{ env.HEAD_SHA }}"
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
with:
|
||||
issue-number: ${{ env.PR_NUMBER }}
|
||||
comment-id: ${{ steps.find-comment.outputs.comment-id }}
|
||||
edit-mode: replace
|
||||
body: |-
|
||||
![badge]
|
||||
|
||||
Build Successful! You can find a link to the downloadable artifact below.
|
||||
|
||||
| Name | Link |
|
||||
| -------- | ----------------------- |
|
||||
| Commit | ${{ env.HEAD_SHA }} |
|
||||
| Logs | ${{ env.JOB_PATH }} |
|
||||
| Download | ${{ env.ARTIFACT_URL }} |
|
||||
|
||||
[badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDAgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg==
|
||||
11
.github/workflows/on_pr_updated.yaml
vendored
Normal file
11
.github/workflows/on_pr_updated.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: ⬇️ PR Updated
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
call_gradle_check:
|
||||
name: ☎️ Call Gradle Check
|
||||
uses: ./.github/workflows/check_gradle_all.yaml
|
||||
secrets: inherit
|
||||
14
.github/workflows/on_pr_updated_completed.yaml
vendored
Normal file
14
.github/workflows/on_pr_updated_completed.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: ✅ PR Updated Completed
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
types:
|
||||
- "completed"
|
||||
workflows:
|
||||
- "⬇️ PR Updated"
|
||||
|
||||
jobs:
|
||||
call_comment_on_pr:
|
||||
name: ☎️ Call Comment on PR
|
||||
uses: ./.github/workflows/check_gradle_all.yaml
|
||||
secrets: inherit
|
||||
Reference in New Issue
Block a user