Skip to content

Commit

Permalink
Try github script
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Dec 4, 2023
1 parent 569da7f commit 8858d34
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions .github/actions/post-checkout/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ runs:

- name: Check for documentation only changes
id: docs-only
run: |
git log --max-count=10;
docs_only="true";
while read filepath; do
if [ $filepath == *.md ]; then
echo "${filepath} is a documentation file";
else
echo "${filepath} is a non documentation file";
docs_only="false";
fi;
done < <(git diff --name-only "${GITHUB_BASE_BRANCH}" "${GITHUB_PR_BRANCH}");
echo "docs_only=${docs_only}" >> $GITHUB_OUTPUT;
shell: bash
env:
GITHUB_BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
GITHUB_PR_BRANCH: ${{ github.event.pull_request.head.ref }}
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
script: |
const opts = github.rest.pulls.listFiles.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
})
const files = await github.paginate(opts)
for (const file of files) {
console.log(file)
if (!file.endsWith('.md')) {
return "false"
}
}
return "true"
result-encoding: string

- name: Get Composer cache directory
id: composer-cache
Expand Down

0 comments on commit 8858d34

Please sign in to comment.