From 59b13a0f3969cfac9c9bb25ed3aa32b4ce5263bf Mon Sep 17 00:00:00 2001 From: ccuser44 <68124053+ccuser44@users.noreply.github.com> Date: Sat, 3 Feb 2024 12:28:22 +0200 Subject: [PATCH 1/2] Create pof_handler.yml --- .github/workflows/pof_handler.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/pof_handler.yml diff --git a/.github/workflows/pof_handler.yml b/.github/workflows/pof_handler.yml new file mode 100644 index 0000000000..cafa0c35d9 --- /dev/null +++ b/.github/workflows/pof_handler.yml @@ -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@v2 + + - 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@v3.1.0 + 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")); From 59004ba6cbc0eea425d58e8c1d8972883b6eac38 Mon Sep 17 00:00:00 2001 From: ccuser44 <68124053+ccuser44@users.noreply.github.com> Date: Sat, 3 Feb 2024 12:41:06 +0200 Subject: [PATCH 2/2] Update dependancies --- .github/workflows/pof_handler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pof_handler.yml b/.github/workflows/pof_handler.yml index cafa0c35d9..fec29fe449 100644 --- a/.github/workflows/pof_handler.yml +++ b/.github/workflows/pof_handler.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4.1.1 - name: Check comment and image run: | @@ -35,7 +35,7 @@ jobs: steps: - name: Remove pof label if: ${{ needs.check_comment_job.outputs.remove_label == 'true' }} - uses: actions/github-script@v3.1.0 + uses: actions/github-script@v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: |