From 3091cd3ad72fa95f11e975115ae982eedd052452 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:17:49 +0100 Subject: [PATCH 1/2] Create restrict-relays-yaml.yaml --- .github/workflows/restrict-relays-yaml.yaml | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/restrict-relays-yaml.yaml diff --git a/.github/workflows/restrict-relays-yaml.yaml b/.github/workflows/restrict-relays-yaml.yaml new file mode 100644 index 00000000..05584566 --- /dev/null +++ b/.github/workflows/restrict-relays-yaml.yaml @@ -0,0 +1,49 @@ +name: Relay PR Response + +on: + pull_request: + paths: + - 'relays.yaml' + types: [opened, synchronize, reopened] + +jobs: + respond-and-close: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Check if User is Allowed + id: check_user + uses: actions/github-script@v5 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const allowedUsers = ['dskvr']; // Replace with actual usernames + const sender = context.payload.pull_request.user.login; + if (allowedUsers.includes(sender)) { + core.setOutput('is_allowed', 'yes'); + } else { + core.setOutput('is_allowed', 'no'); + } + + - name: Comment on PR and Close + if: steps.check_user.outputs.is_allowed == 'no' + uses: actions/github-script@v5 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const prNumber = context.payload.pull_request.number; + const message = "Thank you for your submission, submitting relays is no longer achieved by modification of `relays.yaml`. To submit your relay to nostr.watch simply add your relay to your relays list and ensure you have a known and reachable relay on your relays list when it has been modified. See [here](https://github.com/sandwichfarm/nostr-watch/wiki/How-to-add-a-Relay-to-nostrwatch) for more information"; + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: message + }); + github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + state: "closed" + }); From c6a5516f1e7e02abe3741795041f9f5a2c4c1d78 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:18:20 +0100 Subject: [PATCH 2/2] Update restrict-relays-yaml.yaml --- .github/workflows/restrict-relays-yaml.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/restrict-relays-yaml.yaml b/.github/workflows/restrict-relays-yaml.yaml index 05584566..23312187 100644 --- a/.github/workflows/restrict-relays-yaml.yaml +++ b/.github/workflows/restrict-relays-yaml.yaml @@ -1,4 +1,4 @@ -name: Relay PR Response +name: Restrict relays.yaml on: pull_request: