YAML code snippet:
- name: Get paths to check changes for
id: paths
env:
workflow_ref: ${{ github.workflow_ref }}
run: |
# We sadly don't have yq, so a JS script will have to do
cat <<EOF | bun - >> $GITHUB_OUTPUT
const path = process.env.workflow_ref
.split('@').at(0)
.split('/').slice(2).join('/')
const workflow = await import(`./${path}`)
console.log('files<<EOF')
console.log(workflow.on.pull_request.paths.join('\n'))
console.log('EOF')
EOF
- name: Compute changes with last push
id: changes
uses: tj-actions/changed-files@v47.0.5
with:
since_last_remote_commit: true
files: ${{ steps.paths.outputs.files }}
The yaml module import feature from @bun.sh is very useful if you need to, at runtime, get values from somewhere else within a github actions workflow
for example, if you wanna check changes to the most recent push in a PR, but you already list the files in `on.pull_request.paths`
(untested code)