Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove PoF labels automatically #1396

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/pof_handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Proof-of-work handler

permissions:
issues: write
contents: read

on:
issue_comment:
types: [created]
jobs:
check_comment_job:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4.1.1

- name: Check comment and image
run: |
comment_body=$(jq -r '.comment.body' "$GITHUB_EVENT_PATH")
comment_body_lowercase=$(echo $comment_body | awk '{print tolower($0)}')

if [[ $comment_body_lowercase =~ "(p\-?o\-?f|proof[-_\s]*of[-_\s]*work)\:?.*\!\[.*\]\(.+\)" ]]; then
echo "Found proper pof"
echo "::set-output name=remove_label::true"
else
echo "Proof-of-work invalid or didnt exist"
echo "::set-output name=remove_label::false"
fi

remove_label_job:
needs: check_comment_job
runs-on: ubuntu-latest

steps:
- name: Remove pof label
if: ${{ needs.check_comment_job.outputs.remove_label == 'true' }}
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
async function amogus({ context }) {
const octokit = context.github;
const issue_number = context.payload.issue.number;

await octokit.issues.removeLabel({
...context.repo,
issue_number: issue_number,
name: "⌛needs PoF"
});
}

amogus(require("@actions/github"));
Loading