Skip to content

Commit d7215c3

Browse files
committed
adding engine block action and fixing formatting
1 parent 9335bb9 commit d7215c3

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

.github/workflows/close-inactive-issues-without-repro.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
LABEL_NAME: 'Status: Needs a reproduction link'
2626
LABEL_NAME_URL: 'Status%3A%20Needs%20a%20reproduction%20link'
27-
CUSTOM_MESSAGE: 'In order to investigate further we need a link to a StackBlitz project reproducing the issue. /n /n As this issue has been inactive for 1 day without a reproduction link, it will be closed to allow prioritization of other issues. /n /n If this needs additional investigation, please share a reproduction link by opening a new issue. Thanks for your diligence in helping us continuously improve the StackBlitz platform.'
27+
CUSTOM_MESSAGE: 'In order to investigate further we need a link to a StackBlitz project reproducing the issue. \n \n As this issue has been inactive for 1 day without a reproduction link, it will be closed to allow prioritization of other issues. /n /n If this needs additional investigation, please share a reproduction link by opening a new issue. Thanks for your diligence in helping us continuously improve the StackBlitz platform.'
2828
run: |
2929
set -e
3030
set -x
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Close and Lock Issues with Status Stale Label
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Run every day at midnight
6+
workflow_dispatch: # Allows manual triggering
7+
8+
jobs:
9+
close-issues:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Install Node.js
17+
uses: actions/setup-node@v2
18+
19+
- name: Install jq
20+
run: sudo apt-get update && sudo apt-get install -y jq
21+
22+
- name: Close and lock issues
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
LABEL_NAME: "Status%3A%20EngineBlock"
26+
CUSTOM_MESSAGE: 'Hey there! \n \n It looks like you are using an EngineBlock project, which we recently removed from our starters. You can read more about how we are upgrading our starters here: [Starters Upgrade: WebContainers and Vite](https://blog.stackblitz.com/posts/webcontainers-starters-update/).\n\nMoving forward I would recommend that you see if this problem persists in a WebContainer based project. You can do that by simply clicking one of the links below: \n [node.new](https://node.new) \n [vite.new](https://vite.new) \n Or even more here.\n\nFor now, I am going to close this issue, but feel free to open a new one if you have any issues with the WebContainer based project.'
27+
run: |
28+
set -e # Stop the script if any command fails
29+
set -x # Echo each command before executing it
30+
31+
page=1
32+
while : ; do
33+
echo "Fetching page $page of issues..."
34+
response=$(curl -sS -H "Authorization: token $GITHUB_TOKEN" \
35+
-H "Accept: application/vnd.github.v3+json" \
36+
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues?state=open&labels=$LABEL_NAME&per_page=100&page=$page")
37+
38+
echo $response > issues.json
39+
40+
if [ $(jq length issues.json) -eq 0 ]; then
41+
echo "No more issues found."
42+
break
43+
fi
44+
45+
echo "Commenting, closing, and locking issues..."
46+
jq -c '.[] | .number' issues.json | while read -r issue; do
47+
# Comment on the issue
48+
COMMENT_RESPONSE=$(curl -sS -w "%{http_code}" -X POST -H "Authorization: token $GITHUB_TOKEN" \
49+
-H "Accept: application/vnd.github.v3+json" \
50+
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$issue/comments" \
51+
-d "{\"body\": \"$CUSTOM_MESSAGE\"}")
52+
53+
HTTP_STATUS=$(echo $COMMENT_RESPONSE | rev | cut -c 1-3 | rev)
54+
RESPONSE_BODY=$(echo $COMMENT_RESPONSE | rev | cut -c 4- | rev)
55+
56+
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
57+
echo "Successfully commented on issue $issue."
58+
else
59+
echo "Failed to comment on issue $issue. HTTP Status: $HTTP_STATUS, Response: $RESPONSE_BODY"
60+
exit 1
61+
fi
62+
63+
# Close and lock the issue
64+
RESPONSE=$(curl -sS -w "%{http_code}" -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
65+
-H "Accept: application/vnd.github.v3+json" \
66+
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$issue" \
67+
-d "{\"state\": \"closed\", \"lock_reason\": \"resolved\"}")
68+
69+
HTTP_STATUS=$(echo $RESPONSE | rev | cut -c 1-3 | rev)
70+
RESPONSE_BODY=$(echo $RESPONSE | rev | cut -c 4- | rev)
71+
72+
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
73+
echo "Successfully closed and locked issue $issue."
74+
else
75+
echo "Failed to close and lock issue $issue. HTTP Status: $HTTP_STATUS, Response: $RESPONSE_BODY"
76+
exit 1
77+
fi
78+
done
79+
80+
((page++))
81+
done

0 commit comments

Comments
 (0)