Skip to content

Commit

Permalink
fix: Skip package if the last commit is after the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed Jun 12, 2024
1 parent aa100d7 commit 82c97d1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/package_for_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ jobs:
with:
ref: refs/pull/${{ github.event.issue.number }}/merge

- name: Check without commit after comment
uses: actions/github-script@v7
if: ${{ github.event_name == 'issue_comment' }}
env:
ISSUE_NUMBER: ${{github.event.issue.number}}
COMMENT_ID: ${{ github.event.comment.id }}
with:
script: |
const { ISSUE_NUMBER, COMMENT_ID } = process.env
let page = 1
let hasFoundComment = false
while(true) {
const { data: timelines } = await github.rest.issues.listEventsForTimeline({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ISSUE_NUMBER,
page,
per_page: 100,
})
if (timelines.some(v => {
hasFoundComment = hasFoundComment || (v.event === 'commented' && `${v.id}` === `${COMMENT_ID}`)
return hasFoundComment && v.event === 'committed'
})) {
throw new Error('The last commit comes after the comment, please comment and package after last commit')
}
if (timelines.length === 0) {
return
}
page += 1
}
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down

0 comments on commit 82c97d1

Please sign in to comment.