When I open a pull request, I have a github action set to trigger a node script:
name: Check i18n tokens 🇮🇹
on:
pull_request:
types: [labeled, unlabeled, opened, synchronize, reopened]
branches: ['master']
jobs:
check-I18N-tokens:
needs: generate-matrix
# A check job is performed for each element present in needs.generate-matrix.outputs.matrix. If empty ([]), the job is skipped.
if: ${{ !contains(needs.generate-matrix.outputs.matrix, '[]') }}
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
runs-on: [self-hosted, cdorunner-life-novum, Linux]
container: xxx
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install dependencies
run: yarn
- name: Performing the check
run: yarn perform list-files-changed
...
Where the script performs something like the following:
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {encoding: 'utf8'}).trim();
const diffFilesOutput = execSync(`git diff --name-only $(git merge-base ${currentBranch} master)`, {
encoding: 'utf8',
});
const filesToCheck = diffFilesOutput.split(/r?n/).filter((file) => file.endsWith('.tsx'));
console.log(filesToCheck);
now, it used to work on github actions, but now I got the following:
fatal: Not a valid object name master
so I’m here asking: is there a way to diff the PR against master, without checking out the whole repo? it’s huge and it’d save a lot of resources (and time)
Update
I’ve found a discussion that could be related to this: github checkout discussion
4