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:
|
2023-11-13 00:37:10 +03:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
2023-12-05 15:50:14 +03:00
|
|
|
- id: match-java
|
|
|
|
name: Match Java
|
2024-03-25 23:17:52 +03:00
|
|
|
env:
|
|
|
|
ISSUE_TITLE: ${{ github.event.issue.title }}
|
2023-06-02 20:49:41 +03:00
|
|
|
# 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: |
|
2024-03-25 23:17:52 +03:00
|
|
|
if [[ "$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
|
2023-11-05 22:35:53 +03:00
|
|
|
uses: ./.github/actions/get-labels
|
2023-10-28 22:31:47 +03:00
|
|
|
with:
|
|
|
|
issue_number: ${{ github.event.issue.number }}
|
2023-11-13 00:37:10 +03:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-06-02 20:49:41 +03:00
|
|
|
|
|
|
|
# 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: |
|
2023-12-05 15:50:14 +03:00
|
|
|
steps.match-java.outputs.match == 'true' &&
|
2023-06-02 20:49:41 +03:00
|
|
|
contains(steps.get-labels.outputs.labels, 'new icon')
|
2024-03-09 19:28:21 +03:00
|
|
|
uses: actions/github-script@v7
|
2023-06-02 20:49:41 +03:00
|
|
|
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
|
|
|
});
|