Maintain custom context across middleware #21
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: Assign v3 project and milestone | |
| on: | |
| issues: | |
| types: | |
| - labeled | |
| pull_request_target: | |
| types: | |
| - labeled | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| assign-v3: | |
| if: github.event.label.name == 'v3' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Add item to v3 project | |
| uses: actions/[email protected] | |
| with: | |
| project-url: https://github.com/orgs/gofiber/projects/1 | |
| github-token: ${{ secrets.MILESTONE_PROJECT_TOKEN }} | |
| - name: Assign v3 milestone | |
| uses: actions/github-script@v8 | |
| with: | |
| github-token: ${{ secrets.MILESTONE_PROJECT_TOKEN }} | |
| script: | | |
| const payload = context.eventName === 'issues' ? context.payload.issue : context.payload.pull_request; | |
| const issueNumber = payload.number; | |
| const milestones = await github.paginate(github.rest.issues.listMilestones, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| per_page: 100, | |
| }); | |
| const milestone = milestones.find((item) => item.title === 'v3'); | |
| if (!milestone) { | |
| throw new Error('Milestone "v3" was not found.'); | |
| } | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| milestone: milestone.number, | |
| }); |