Skip to content

Commit a5e5949

Browse files
committed
feat: refactor commenting actions to use built-in gh command
1 parent aa8199f commit a5e5949

File tree

9 files changed

+55
-86
lines changed

9 files changed

+55
-86
lines changed

.github/comments/issue-fixed.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Thank you for your report; the issue you have reported has just been fixed.
2+
3+
- In case you see a problem with the fix, please comment on this issue.
4+
- In case you see a similar problem, please open a separate issue.
5+
- If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://weblate.org/donate/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Copyright © Michal Čihař <michal@weblate.org>
2+
3+
SPDX-License-Identifier: CC0-1.0

.github/comments/issue-newbie.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This issue seems to be a good fit for newbie contributors.
2+
You are welcome to contribute to Weblate! Don't hesitate to
3+
ask any questions you would have while implementing this.
4+
5+
You can learn about how to get started in our
6+
[contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Copyright © Michal Čihař <michal@weblate.org>
2+
3+
SPDX-License-Identifier: CC0-1.0

.github/comments/issue-resolved.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.
2+
3+
- In case you see a similar problem, please open a separate issue.
4+
- If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://weblate.org/donate/).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Copyright © Michal Čihař <michal@weblate.org>
2+
3+
SPDX-License-Identifier: CC0-1.0

.github/workflows/closing.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ permissions:
1919
jobs:
2020
issueClosed:
2121
permissions:
22-
issues: write # for peter-evans/create-or-update-comment to create or update comment
23-
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
22+
issues: write # for gh issue comment
2423
runs-on: ubuntu-slim
2524
steps:
25+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
with:
27+
persist-credentials: false
2628
- name: Add closed question comment
27-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
2829
if: |
2930
github.actor != 'renovate[bot]' &&
3031
github.event.issue.state_reason == 'completed' &&
@@ -33,16 +34,11 @@ jobs:
3334
! contains(github.event.issue.labels.*.name, 'duplicate') &&
3435
! contains(github.event.issue.labels.*.name, 'wontfix')
3536
) || join(github.event.issue.labels.*.name) == '')
36-
with:
37-
token: ${{ secrets.GITHUB_TOKEN }}
38-
issue-number: ${{ github.event.issue.number }}
39-
body: |
40-
The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.
41-
42-
* In case you see a similar problem, please open a separate issue.
43-
* If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://weblate.org/donate/).
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
ISSUE_NUMBER: ${{ github.event.issue.number }}
40+
run: gh issue comment "$ISSUE_NUMBER" --body-file .github/comments/issue-resolved.md
4441
- name: Add closed issue comment
45-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
4642
if: |
4743
github.actor != 'renovate[bot]' &&
4844
github.event.issue.state_reason == 'completed' &&
@@ -53,12 +49,7 @@ jobs:
5349
! contains(github.event.issue.labels.*.name, 'undecided') &&
5450
! contains(github.event.issue.labels.*.name, 'needinfo') &&
5551
join(github.event.issue.labels.*.name) != ''
56-
with:
57-
token: ${{ secrets.GITHUB_TOKEN }}
58-
issue-number: ${{ github.event.issue.number }}
59-
body: |
60-
Thank you for your report; the issue you have reported has just been fixed.
61-
62-
* In case you see a problem with the fix, please comment on this issue.
63-
* In case you see a similar problem, please open a separate issue.
64-
* If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://weblate.org/donate/).
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
ISSUE_NUMBER: ${{ github.event.issue.number }}
55+
run: gh issue comment "$ISSUE_NUMBER" --body-file .github/comments/issue-fixed.md

.github/workflows/labels.yml

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,15 @@ permissions:
1515
jobs:
1616
issueLabeled:
1717
permissions:
18-
issues: write # for peter-evans/create-or-update-comment to create or update comment
19-
pull-requests: write # for peter-evans/create-or-update-comment to create or update comment
18+
issues: write # for gh issue comment
2019
runs-on: ubuntu-slim
2120
steps:
22-
- name: Add backlog comment
23-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
24-
if: ${{ github.event.label.name == 'backlog' }}
21+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2522
with:
26-
token: ${{ secrets.GITHUB_TOKEN }}
27-
issue-number: ${{ github.event.issue.number }}
28-
body: >
29-
This issue has been added to the backlog. It is not scheduled
30-
on the Weblate roadmap, but it eventually might be implemented.
31-
32-
33-
In case you need this feature soon, please consider helping
34-
or push it by [funding the development](https://weblate.org/support/).
35-
- name: Add undecided comment
36-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
37-
if: ${{ github.event.label.name == 'undecided' }}
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
40-
issue-number: ${{ github.event.issue.number }}
41-
body: >
42-
This issue has been put aside. It is currently unclear if it will
43-
ever be implemented as it seems to cover too narrow of a use case
44-
or doesn't seem to fit into Weblate.
45-
46-
47-
Please try to clarify the use case or consider proposing something more generic to make it useful to more users.
48-
- name: Add question comment
49-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
50-
if: ${{ github.event.label.name == 'question' }}
51-
with:
52-
token: ${{ secrets.GITHUB_TOKEN }}
53-
issue-number: ${{ github.event.issue.number }}
54-
body: >
55-
This issue has been marked as a question by a Weblate team member.
56-
Why? Because it belongs more to the professional [Weblate Care](https://care.weblate.org/)
57-
or community [Discussions](https://github.com/WeblateOrg/weblate/discussions) than here.
58-
We strive to answer these reasonably fast here, too, but
59-
[purchasing the support subscription](https://weblate.org/support/)
60-
is more responsible and faster for your business.
61-
And it makes Weblate stronger as well. Thanks!
62-
63-
64-
In case your question is already answered, [making a donation](https://weblate.org/donate/) is the right way to say thank you!
65-
- name: Add translate-toolkit comment
66-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
67-
if: ${{ github.event.label.name == 'translate-toolkit' }}
68-
with:
69-
token: ${{ secrets.GITHUB_TOKEN }}
70-
issue-number: ${{ github.event.issue.number }}
71-
body: >
72-
The issue you've reported needs to be addressed in the [translate-toolkit](https://github.com/translate/translate/).
73-
Please file the issue there, and include links to any relevant specifications about the formats (if applicable).
23+
persist-credentials: false
7424
- name: Add good first issue comment
75-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
7625
if: ${{ github.event.label.name == 'good first issue' }}
77-
with:
78-
token: ${{ secrets.GITHUB_TOKEN }}
79-
issue-number: ${{ github.event.issue.number }}
80-
body: >
81-
This issue seems to be a good fit for newbie contributors.
82-
You are welcome to contribute to Weblate! Don't hesitate to
83-
ask any questions you would have while implementing this.
84-
85-
86-
You can learn about how to get started in our
87-
[contributors documentation](https://docs.weblate.org/en/latest/contributing/index.html).
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
ISSUE_NUMBER: ${{ github.event.issue.number }}
29+
run: gh issue comment "$ISSUE_NUMBER" --body-file .github/comments/issue-newbie.md

sync.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ COPYFILES="
5353
.github/ISSUE_TEMPLATE/feature_request.yml
5454
"
5555

56+
# Automated comments
57+
COMMENTFILES="
58+
.github/comments/issue-fixed.md
59+
.github/comments/issue-resolved.md
60+
.github/comments/issue-newbie.md
61+
"
5662
# Update these files if present
5763
PRESENTFILES="
5864
.github/workflows/closing.yml
@@ -65,6 +71,7 @@ PRESENTFILES="
6571
.github/release.yml
6672
.eslintrc.yml
6773
.stylelintrc
74+
$COMMENTFILES
6875
"
6976

7077
# Files to remove
@@ -161,6 +168,11 @@ for repo in $REPOS; do
161168
rm "$file"
162169
fi
163170
done
171+
if [ -f .github/workflows/closing.yml ] || [ -f .github/workflows/labels.yml ]; then
172+
for file in $COMMENTFILES; do
173+
copyfile "$file" "$repo"
174+
done
175+
fi
164176

165177
# Configure GitHub release notes generating
166178
if grep -q generateReleaseNotes .github/workflows/*; then

0 commit comments

Comments
 (0)