chore: changeset check #20
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=$(echo "$ALL_CHANGED_FILES" | grep ".changeset") | |
echo "文件列表:$files" | |
major_changes=$(grep -c "major" $files) | |
echo "$major_changes major changes found." | |
if [ "$major_changes" -gt 0 ]; then | |
comment="major" | |
echo "comment=$comment" >> $GITHUB_OUTPUT | |
else | |
echo "comment=" >> $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 | |
$(grep "major" $files) | |
\`\`\` | |
<!-- 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 |