diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 9b6cac3..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Java CI -on: - - push - - pull_request_target -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: gradle - - name: Build with Gradle - run: ./gradlew build - - uses: mate-academy/auto-approve-action@v2 - if: ${{ github.event.pull_request && success() }} - with: - github-token: ${{ github.token }} - - uses: mate-academy/auto-reject-action@v2 - if: ${{ github.event.pull_request && failure() }} - with: - github-token: ${{ github.token }} diff --git a/.github/workflows/pr-review.yml b/.github/workflows/pr-review.yml new file mode 100644 index 0000000..5c55ed5 --- /dev/null +++ b/.github/workflows/pr-review.yml @@ -0,0 +1,40 @@ +name: PR Review + +on: + workflow_run: + workflows: [Test] + types: [completed] + +permissions: + pull-requests: write + actions: read + contents: read + +jobs: + review: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.event == 'pull_request' }} + + steps: + - name: Download PR number + uses: actions/download-artifact@v4 + with: + name: pr-number + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Read PR number + id: pr + run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT" + + - uses: mate-academy/auto-approve-action@v2 + if: ${{ github.event.workflow_run.conclusion == 'success' }} + with: + github-token: ${{ github.token }} + pull-request-number: ${{ steps.pr.outputs.number }} + + - uses: mate-academy/auto-reject-action@v2 + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + with: + github-token: ${{ github.token }} + pull-request-number: ${{ steps.pr.outputs.number }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ea7c351 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + - name: Build with Gradle + run: ./gradlew build + + - name: Save PR number + if: ${{ !cancelled() && github.event_name == 'pull_request' }} + run: echo "${{ github.event.pull_request.number }}" > pr-number.txt + + - name: Upload PR number + if: ${{ !cancelled() && github.event_name == 'pull_request' }} + uses: actions/upload-artifact@v4 + with: + name: pr-number + path: pr-number.txt