forked from ProjectOmu/OmuStation
-
Notifications
You must be signed in to change notification settings - Fork 0
Update README.md #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NotActuallyMarty
wants to merge
4
commits into
master
Choose a base branch
from
aaaa
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update README.md #14
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,90 +1,128 @@ | ||
| # SPDX-FileCopyrightText: 2024 Myra <vasilis@pikachu.systems> | ||
| # SPDX-FileCopyrightText: 2024 Saphire Lattice <lattice@saphi.re> | ||
| # SPDX-FileCopyrightText: 2024 Vasilis <vasilis@pikachu.systems> | ||
| # 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaacrazyyYyyy