|
23 | 23 | runs-on: ubuntu-latest |
24 | 24 | steps: |
25 | 25 | - name: Update project status by solving label |
| 26 | + id: update-status |
26 | 27 | env: |
27 | 28 | GH_TOKEN: ${{ secrets.ONE_PROBLEM_ONE_DAY_PAT }} |
28 | 29 | run: | |
|
66 | 67 | | .id") |
67 | 68 | if [[ -z "$item_id" ]]; then |
68 | 69 | echo "Issue not in project, skip" |
| 70 | + echo "skip=true" >> $GITHUB_OUTPUT |
69 | 71 | exit 0 |
70 | 72 | fi |
71 | 73 | echo "Found item_id = $item_id" |
|
79 | 81 | status="Todo" |
80 | 82 | fi |
81 | 83 | fi |
| 84 | + echo "status=$status" >> $GITHUB_OUTPUT |
82 | 85 | echo "Target status name = $status" |
83 | 86 |
|
84 | 87 | echo "Resolve status option ID..." |
@@ -149,3 +152,41 @@ jobs: |
149 | 152 | -F option="$option_id" |
150 | 153 | fi |
151 | 154 | 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 | + }); |
0 commit comments