2023-06-02 20:49:41 +03:00
|
|
|
name: Autocloser
|
|
|
|
on:
|
|
|
|
issues:
|
2023-06-02 21:32:53 +03:00
|
|
|
# we allow 'reopend' and 'edited' in case the issue was closed by accident
|
|
|
|
types: [opened]
|
2023-06-02 20:49:41 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
run:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- id: match-title
|
|
|
|
name: Match title
|
|
|
|
# if the title contains the word Java (case insensitive)
|
|
|
|
# we make sure that this word is the end of the string or is followed by a space character (ex. we do not want to match javascript)
|
|
|
|
# we make sure that this word is the beginning of the string or is preceded by a space character (ex. we do not want to match foojava)
|
|
|
|
run: |
|
2023-06-02 21:12:51 +03:00
|
|
|
if [[ "${{ github.event.issue.title }}" =~ (^|[[:space:]])([jJ][aA][vV][aA])([[:space:]]|$) ]]; then
|
2023-06-02 20:49:41 +03:00
|
|
|
echo "match=true" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
|
|
|
|
- id: get-labels
|
|
|
|
name: Get labels
|
|
|
|
run: |
|
2023-06-02 21:39:26 +03:00
|
|
|
labels="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons/issues/${{ github.event.issue.number }} | jq '.labels[].name' | tr '\n' ',' | sed -e 's/"//g' -e 's/,$//')"
|
2023-06-02 20:49:41 +03:00
|
|
|
echo "labels=$labels" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
# if the issue is labeled as a 'new icon' and it matches Java, we
|
|
|
|
# - add a comment referring to the removal request
|
|
|
|
# - we add the 'duplicate' label
|
|
|
|
# - we close the issue
|
|
|
|
- name: Close the issue
|
|
|
|
if: |
|
|
|
|
steps.match-title.outputs.match == 'true' &&
|
|
|
|
contains(steps.get-labels.outputs.labels, 'new icon')
|
|
|
|
uses: actions/github-script@v6
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
github.rest.issues.createComment({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
body: 'This issue was automatically closed. Please refer to #7374.'
|
|
|
|
})
|
|
|
|
github.rest.issues.addLabels({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: ['duplicate']
|
|
|
|
})
|
|
|
|
github.rest.issues.update({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2023-06-04 02:14:30 +03:00
|
|
|
state: 'closed',
|
|
|
|
state_reason: 'not_planned'
|
2023-06-02 20:49:41 +03:00
|
|
|
});
|