Skip to content

Commit

Permalink
Update issues.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Sep 9, 2024
1 parent d227ac9 commit 57f8240
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Encode issue body to base64
id: encode_body
run: |
echo "::set-output name=body_base64::$(echo -n '${{ github.event.issue.body }}' | base64)"
- name: Check issue body for regex
id: check_regex
run: |
ISSUE_BODY=$(echo "${{ steps.encode_body.outputs.body_base64 }}" | base64 --decode)
if [[ ! $ISSUE_BODY =~ 345567 ]]; then
echo "::set-output name=should_close::true"
else
echo "::set-output name=should_close::false"
fi
- name: Close issue
if: steps.check_regex.outputs.should_close == 'true'
- name: Check issue body and close if necessary
uses: actions/github-script@v6
with:
script: |
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed'
})
const issueBody = context.payload.issue.body || '';
const regex = /345567/;
if (!regex.test(issueBody)) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed'
});
console.log(`Issue #${context.issue.number} closed because it did not match the regex.`);
} else {
console.log(`Issue #${context.issue.number} remains open because it matches the regex.`);
}

0 comments on commit 57f8240

Please sign in to comment.