Skip to content

Commit

Permalink
fix: issue_comment run
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Oct 21, 2024
1 parent ee6ea20 commit 7ff7627
Show file tree
Hide file tree
Showing 2 changed files with 564 additions and 2 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/update-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,50 @@ jobs:
prettier: ${{ false || steps.filter.outputs.prettier }}
stylelint: ${{ false || steps.filter.outputs.stylelint }}
permissions:
pull-requests: read
contents: read

steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0

- name: Get PR information
id: pr-request
uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0
with:
route: ${{ github.event.issue.pull_request.url }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Exit if invalid PR
run: |
if [ "${{ fromJson(steps.pr-request.outputs.data).base.ref }}" != 'main' ]; then
echo "::error::PR base branch is not main."
exit 1
fi
if [ "${{ fromJson(steps.pr-request.outputs.data).state }}" != 'open' ]; then
echo "::error::PR is not open."
exit 1
fi
if [ "${{ fromJson(steps.pr-request.outputs.data).draft }}" == 'true' ]; then
echo "::error::Cannot update snapshot for draft PR."
exit 1
fi
- name: Checkout PR
run: |
gh pr checkout ${{ github.event.issue.number }}
env:
GH_TOKEN: ${{ github.token }}

- name: Check changed packages (PR Comment)
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == '/update-snapshot'
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && !contains(github.event.comment.user.name, 'bot') && contains(github.event.comment.body, '/update-snapshot')
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
base: main
filters: |
eslint:
- 'packages/eslint-config/**'
Expand Down
Loading

0 comments on commit 7ff7627

Please sign in to comment.