chore: changeset check #29
Workflow file for this run
This file contains 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: PR Changeset Check | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
check_changeset: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Changed Files | |
id: changed-files | |
uses: tj-actions/[email protected] | |
with: | |
files: | | |
.changeset/**.md | |
- name: Check for major changes | |
id: check_changeset | |
env: | |
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
run: | | |
files=$ALL_CHANGED_FILES | |
echo "File list: $files" | |
major_changes=$(grep "major" $files) | |
if [ $? -eq 0 ]; then | |
echo "Not found major changes." | |
comment="" | |
echo "comment=$comment" >> $GITHUB_OUTPUT | |
else | |
echo "Found major changes." | |
echo "comment=$major_changes" >> $GITHUB_OUTPUT | |
fi | |
- name: update status comment | |
if: ${{ steps.check_changeset.outputs.comment != '' }} | |
uses: actions-cool/maintain-one-comment@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
@${{ github.actor }}, 本次 PR 的更改包含 major 变更,请确认是否符合预期。 | |
```md | |
${{ steps.check_changeset.outputs.comment }} | |
``` | |
<!-- AUTO_CHANGESET_CHECK_HOOK --> | |
body-include: '<!-- AUTO_CHANGESET_CHECK_HOOK -->' | |
number: ${{ github.event.pull_request.number }} | |
- name: Delete comment | |
if: ${{ steps.check_changeset.outputs.comment == '' }} | |
uses: actions-cool/maintain-one-comment@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body-include: '<!-- AUTO_CHANGESET_CHECK_HOOK -->' | |
number: ${{ github.event.pull_request.number }} | |
delete: true |