diff --git a/.github/workflows/labeler-dispatch.yml b/.github/workflows/labeler-dispatch.yml new file mode 100644 index 00000000000..f1b1eaafde9 --- /dev/null +++ b/.github/workflows/labeler-dispatch.yml @@ -0,0 +1,20 @@ +# This thing basically exists due to limitations of pull_request_review +# basically: +# "With the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository. +# The GITHUB_TOKEN has read-only permissions in pull requests from forked repositories. For more information, see Use GITHUB_TOKEN for authentication in workflows." +# +# ^ and yeah, that also means you cannot give any more permissions to this either. +# so i'm having this run and running a diff workflow when this finishes. Worst that could happen is someone fucks with labels + +name: "Review Trigger" + +on: + pull_request_review_comment: + types: [edited] + +jobs: + noop: + runs-on: ubuntu-latest + steps: + - name: Dummy step + run: echo "This is so incredibly fucking stupid" diff --git a/.github/workflows/labeler-review.yml b/.github/workflows/labeler-review.yml index 19fc130a6f3..dcf81fbe8ce 100644 --- a/.github/workflows/labeler-review.yml +++ b/.github/workflows/labeler-review.yml @@ -1,90 +1,128 @@ -# SPDX-FileCopyrightText: 2024 Myra -# SPDX-FileCopyrightText: 2024 Saphire Lattice -# SPDX-FileCopyrightText: 2024 Vasilis -# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com> -# -# SPDX-License-Identifier: AGPL-3.0-or-later - +# This is shit and needs cleanup but since we are technically running this after a workflow that runs on the fork and not master i kinda want to make sure we use nothing from that workflow +# Forgive me for the mess. name: "Labels: Approved" on: - pull_request_review: - types: [submitted] + workflow_run: + workflows: ["Review Trigger"] + types: [completed] jobs: label-on-approval: + if: | + github.event.workflow_run.name == 'Review Trigger' && + github.event.workflow_run.event == 'pull_request_review_comment' && + github.event.workflow_run.repository.full_name == github.repository && + github.event.workflow_run.pull_requests[0].number != null + runs-on: ubuntu-latest + permissions: contents: read issues: write pull-requests: write - runs-on: ubuntu-latest + steps: - - name: Create JSON File - id: curling-reviews - run: | - PR_NUMBER=${{ github.event.pull_request.number }} - OWNER=${{ github.repository_owner }} - REPO=${{ github.event.repository.name }} - TOKEN=${{ secrets.GITHUB_TOKEN }} - - # Fetch the reviews and place them into a json file. - curl -o reviews.json -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/reviews - - - name: Check for Approvals - id: check-approvals - run: | - # Count the number of approvals - APPROVALS=$(jq '[.[] | select(.state=="APPROVED")] | length' reviews.json) - - echo "Number of approvals: $APPROVALS" - echo "::set-output name=approvals::$APPROVALS" - - - name: Add Approved Label if Enough Approvals - if: steps.check-approvals.outputs.approvals >= 2 # Change the threshold here - uses: actions-ecosystem/action-add-labels@v1 - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - with: - labels: "S: Approved" - - - name: Remove Other Labels on Approved - if: steps.check-approvals.outputs.approvals >= 2 - uses: actions-ecosystem/action-remove-labels@v1 - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - with: - labels: | - "S: Needs Review" - "S: Needs Second Approval" - - - name: Add Second Approval Requirement on Approval - if: steps.check-approvals.outputs.approvals == 1 - uses: actions-ecosystem/action-add-labels@v1 - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - with: - labels: | - "S: Needs Second Approval" - "S: Needs Review" - - - name: Remove Other Labels on Second Approval Requirement - if: steps.check-approvals.outputs.approvals == 1 - uses: actions-ecosystem/action-remove-labels@v1 - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - with: - labels: "S: Approved" - - - name: Remove All Other Labels if No Approval - if: steps.check-approvals.outputs.approvals < 1 - uses: actions-ecosystem/action-remove-labels@v1 - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - with: - labels: | - "S: Approved" - "S: Needs Second Approval" + - name: Extract PR metadata + id: meta + run: | + PR_NUMBER=$(jq -r '.workflow_run.pull_requests[0].number' "$GITHUB_EVENT_PATH") + HEAD_SHA=$(jq -r '.workflow_run.head_sha' "$GITHUB_EVENT_PATH") + + echo "pr=$PR_NUMBER" >> $GITHUB_OUTPUT + echo "sha=$HEAD_SHA" >> $GITHUB_OUTPUT + + - name: Verify PR exists and SHA matches + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + PR_NUMBER: ${{ steps.meta.outputs.pr }} + HEAD_SHA: ${{ steps.meta.outputs.sha }} + run: | + curl -o pr.json \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER + + API_SHA=$(jq -r '.head.sha' pr.json) + + if [ "$API_SHA" != "$HEAD_SHA" ]; then + echo "Commit SHA mismatch" + exit 1 + fi + + - name: Fetch reviews + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + PR_NUMBER: ${{ steps.meta.outputs.pr }} + run: | + curl -o reviews.json -L \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/$OWNER/$REPO/pulls/$PR_NUMBER/reviews + + - name: Count approvals + id: check-approvals + run: | + APPROVALS=$(jq ' + group_by(.user.login) + | map(last) + | map(select(.state=="APPROVED" and .user.type=="User")) + | length + ' reviews.json) + + echo "Number of approvals: $APPROVALS" + echo "approvals=$APPROVALS" >> $GITHUB_OUTPUT + + - name: Add Approved Label if Enough Approvals + if: steps.check-approvals.outputs.approvals == 2 + uses: actions-ecosystem/action-add-labels@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + number: ${{ steps.meta.outputs.pr }} + labels: "S: Approved" + + - name: Remove Other Labels on Approved + if: steps.check-approvals.outputs.approvals >= 2 + uses: actions-ecosystem/action-remove-labels@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + number: ${{ steps.meta.outputs.pr }} + labels: | + "S: Needs Review" + "S: Needs Second Approval" + + - name: Add Second Approval Requirement + if: steps.check-approvals.outputs.approvals == 1 + uses: actions-ecosystem/action-add-labels@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + number: ${{ steps.meta.outputs.pr }} + labels: | + "S: Needs Second Approval" + "S: Needs Review" + + - name: Remove Other Labels on Second Approval + if: steps.check-approvals.outputs.approvals == 1 + uses: actions-ecosystem/action-remove-labels@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + number: ${{ steps.meta.outputs.pr }} + labels: "S: Approved" + + - name: Remove Labels if No Approval + if: steps.check-approvals.outputs.approvals == 1 + uses: actions-ecosystem/action-remove-labels@v1 + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + with: + number: ${{ steps.meta.outputs.pr }} + labels: | + "S: Approved" + "S: Needs Second Approval" diff --git a/README.md b/README.md index 84cd3db0d96..413bd9bc826 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

Space Station 14

-This is a fork from [Goob Station](https://github.com/Goob-Station/Goob-Station), a primary fork from [Space Station 14](https://github.com/space-wizards/space-station-14). To prevent people forking [Robust Toolbox](https://github.com/space-wizards/RobustToolbox), a "content" pack is loaded by the client and server. This content pack contains everything needed to play the game on one specific server this is the content pack for Omu Station. +Thias is a fork from [Goob Station](https://github.com/Goob-Station/Goob-Station), a primary fork from [Space Station 14](https://github.com/space-wizards/space-station-14). To prevent people forking [Robust Toolbox](https://github.com/space-wizards/RobustToolbox), a "content" pack is loaded by the client and server. This content pack contains everything needed to play the game on one specific server this is the content pack for Omu Station. Omu Station strives to be a fork focused on more roleplay-centric gameplay while still focusing on community. We intend to take more mechanics from other forks and build a place where everyone can enjoy and play a unique shift every round.