添加文件变更检查步骤以决定是否执行构建和部署
This commit is contained in:
parent
ab2afef68a
commit
670e061545
@ -6,7 +6,38 @@ on:
|
|||||||
types: [opened,synchronize]
|
types: [opened,synchronize]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-file-changes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_run: ${{ steps.filter.outputs.should_run }}
|
||||||
|
steps:
|
||||||
|
- name: 🚚 Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: 📑 Check changed files
|
||||||
|
id: filter
|
||||||
|
run: |
|
||||||
|
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} || git diff --name-only HEAD~1 HEAD)
|
||||||
|
|
||||||
|
MD_ONLY=true
|
||||||
|
for file in $CHANGED_FILES; do
|
||||||
|
if [[ ! $file =~ \.md$ ]]; then
|
||||||
|
MD_ONLY=false
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$MD_ONLY" = false ] || [ -z "$CHANGED_FILES" ]; then
|
||||||
|
echo "should_run=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "should_run=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
|
needs: check-file-changes
|
||||||
|
if: ${{ needs.check-file-changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
Loading…
x
Reference in New Issue
Block a user