Submission - RWA Auction #243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Submission Issue Automation | |
| on: | |
| issues: | |
| types: [opened, closed] | |
| permissions: | |
| contents: write | |
| issues: write | |
| concurrency: | |
| group: hackathon-automation-${{ github.event.issue.number }} | |
| cancel-in-progress: false | |
| jobs: | |
| process-submission: | |
| runs-on: ubuntu-latest | |
| if: | | |
| (github.event.action == 'opened' && startsWith(github.event.issue.title, 'Submission')) || | |
| (github.event.action == 'closed' && github.event.issue.state_reason == 'completed' && startsWith(github.event.issue.title, 'Submission') && github.actor != 'github-actions[bot]') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Submission Info, Create Project Folder and Update Table | |
| id: extract-submission | |
| run: | | |
| node materials/scripts/submission_extract.js | |
| env: | |
| ISSUE_BODY: ${{ github.event.issue.body }} | |
| ISSUE_USER: ${{ github.event.issue.user.login }} | |
| - name: Comment and close issue | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.payload.issue.number; | |
| const user = context.payload.issue.user.login; | |
| try { | |
| // 添加成功处理的评论 | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number, | |
| body: `✅ Submission processed successfully! ${context.payload.action === 'opened' ? '(Auto)' : '(Manual)'}` | |
| }); | |
| // 只有在自动触发时才关闭 issue | |
| if (context.payload.action === 'opened') { | |
| await github.rest.issues.update({ | |
| owner, | |
| repo, | |
| issue_number, | |
| state: 'closed', | |
| state_reason: 'completed' | |
| }); | |
| } | |
| console.log(`✅ Issue #${issue_number} processed and closed successfully`); | |
| } catch (error) { | |
| console.error(`Error processing issue: ${error.message}`); | |
| core.setFailed(`Error processing issue: ${error.message}`); | |
| } |