Skip to content

Commit 312fd2c

Browse files
committed
1problem1day: comment - 未测试
哎呀,重复代码越来越多了
1 parent bba51e1 commit 312fd2c

File tree

7 files changed

+114
-9
lines changed

7 files changed

+114
-9
lines changed

.github/workflows/1problem1day-addNewIssue2project.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ jobs:
6565
-f item="$item_id" \
6666
-f field="$DATE_FIELD_ID" \
6767
-f date="$date_cn"
68-
69-
# This issue was automatically added to the project.
70-
# 🕒 Time (Beijing, UTC+8): 2025-12-22 13:45:32
71-
# 🤖 Triggered by GitHub Actions
72-
# appid: 2517117
73-
# installation id: 100703634
68+
69+
- name: Resolve workflow path
70+
id: resolve-workflow-path
71+
env:
72+
REPO: ${{ github.repository }}
73+
run: |
74+
workflow_path=${GITHUB_WORKFLOW_REF#*/}
75+
workflow_path=${workflow_path%@*}
76+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
77+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
7478
7579
- name: Generate GitHub App token
7680
id: app-token
@@ -89,9 +93,11 @@ jobs:
8993
hour12: false
9094
});
9195
96+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`
97+
9298
await github.rest.issues.createComment({
9399
owner: context.repo.owner,
94100
repo: context.repo.repo,
95101
issue_number: context.issue.number,
96-
body: `This issue was automatically added to the project.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day)`
97-
});
102+
body: `This issue was automatically added to the project.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
103+
});

.github/workflows/1problem1day-autoGenIssueEveryday.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
4747
gh issue create \
4848
--title "[newSolution]Who can add 1 more problem of LeetCode $id" \
49-
--body "By Github [Actions](https://github.com/$REPO/tree/$GITHUB_SHA/$workflow_path) | [$id.$title](https://leetcode.cn/problems/$slug/) | $date" \
49+
--body "By Github [Actions](https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path) | [$id.$title](https://leetcode.cn/problems/$slug/) | $date" \
5050
--label 题解 \
5151
--assignee LetMeFly666 \
5252
--repo "$REPO"

.github/workflows/1problem1day-closeAndSetDate.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Set finish date & done
21+
id: set-state
2122
env:
2223
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
2324
run: |
@@ -45,6 +46,7 @@ jobs:
4546
| .id")
4647
if [[ -z "$item_id" ]]; then
4748
echo "Issue not in project, skip"
49+
echo "skip=true" >> $GITHUB_OUTPUT
4850
exit 0
4951
fi
5052
echo "Found item_id = $item_id"
@@ -66,4 +68,43 @@ jobs:
6668
-f item="$item_id" \
6769
-f field="$FINISH_DATE_FIELD_ID" \
6870
-f date="$date_cn"
71+
echo "date_cn=$date_cn" >> $GITHUB_OUTPUT
6972
echo "Set Finish Date successfully ✅"
73+
74+
- name: Resolve workflow path
75+
id: resolve-workflow-path
76+
if: steps.set-state.outputs.skip != 'true'
77+
env:
78+
REPO: ${{ github.repository }}
79+
run: |
80+
workflow_path=${GITHUB_WORKFLOW_REF#*/}
81+
workflow_path=${workflow_path%@*}
82+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
83+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
84+
85+
- name: Generate GitHub App token
86+
id: app-token
87+
uses: actions/create-github-app-token@v1
88+
with:
89+
app-id: ${{ vars.DAILY_BOT_APP_ID }}
90+
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
91+
92+
- name: Comment on issue
93+
uses: actions/github-script@v7
94+
with:
95+
github-token: ${{ steps.app-token.outputs.token }}
96+
script: |
97+
const now = new Date().toLocaleString('zh-CN', {
98+
timeZone: 'Asia/Shanghai',
99+
hour12: false
100+
});
101+
102+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`;
103+
const setToDate = `${{ steps.set-state.outputs.date_cn }}`;
104+
105+
await github.rest.issues.createComment({
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
issue_number: context.issue.number,
109+
body: `Set finish date = ${setToDate} in project.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
110+
});

.github/workflows/1problem1day-label.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Update project status by solving label
26+
id: update-status
2627
env:
2728
GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }}
2829
run: |
@@ -66,6 +67,7 @@ jobs:
6667
| .id")
6768
if [[ -z "$item_id" ]]; then
6869
echo "Issue not in project, skip"
70+
echo "skip=true" >> $GITHUB_OUTPUT
6971
exit 0
7072
fi
7173
echo "Found item_id = $item_id"
@@ -79,6 +81,7 @@ jobs:
7981
status="Todo"
8082
fi
8183
fi
84+
echo "status=$status" >> $GITHUB_OUTPUT
8285
echo "Target status name = $status"
8386
8487
echo "Resolve status option ID..."
@@ -149,3 +152,41 @@ jobs:
149152
-F option="$option_id"
150153
fi
151154
echo "Status updated successfully ✅"
155+
156+
- name: Resolve workflow path
157+
id: resolve-workflow-path
158+
if: steps.update-status.outputs.skip != 'true'
159+
env:
160+
REPO: ${{ github.repository }}
161+
run: |
162+
workflow_path=${GITHUB_WORKFLOW_REF#*/}
163+
workflow_path=${workflow_path%@*}
164+
action_file="https://github.com/$REPO/blob/$GITHUB_SHA/$workflow_path"
165+
echo "action_file=$action_file" >> $GITHUB_OUTPUT
166+
167+
- name: Generate GitHub App token
168+
id: app-token
169+
uses: actions/create-github-app-token@v1
170+
with:
171+
app-id: ${{ vars.DAILY_BOT_APP_ID }}
172+
private-key: ${{ secrets.DAILY_BOT_APP_PRIVATE_KEY }}
173+
174+
- name: Comment on issue
175+
uses: actions/github-script@v7
176+
with:
177+
github-token: ${{ steps.app-token.outputs.token }}
178+
script: |
179+
const now = new Date().toLocaleString('zh-CN', {
180+
timeZone: 'Asia/Shanghai',
181+
hour12: false
182+
});
183+
184+
const actionFile = `${{ steps.resolve-workflow-path.outputs.action_file }}`;
185+
const status = `${{ steps.update-status.outputs.status }}`;
186+
187+
await github.rest.issues.createComment({
188+
owner: context.repo.owner,
189+
repo: context.repo.repo,
190+
issue_number: context.issue.number,
191+
body: `Set the project status to ${status} based on the \`solving\` label.\n🕒 Time (Beijing, UTC+8): ${now}\n🤖 Triggered by [1problem1day Bot](https://github.com/apps/1problem1day) according to [action file](${actionFile})`
192+
});

a.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2025-12-21 21:13:14
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2025-12-21 21:13:30
6+
*/
7+
#include <stdio.h>
8+
9+
int main() {
10+
int a = 0, b = 0;
11+
a = 10; // ??/
12+
b = 20;
13+
printf("a+b=%d", a + b);
14+
return 0;
15+
}

a.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gcc -trigraphs a.c; ./a.exe

todo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sync LeetCode-test repo

0 commit comments

Comments
 (0)