ci: fetch only the number of commits needed for checks #2
Workflow file for this run
This file contains hidden or 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
| on: | ||
|
Check failure on line 1 in .github/workflows/semantic-git-message.yml
|
||
| workflow_call: | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| calculate-depth: | ||
| name: Calculate commits in the PR | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| calculated_depth: ${{ steps.calc.outputs.depth }} | ||
| steps: | ||
| - name: Compute the required fetch_depth | ||
| id: calc | ||
| run: | | ||
| PR_COMMITS=${{ github.event.pull_request.commits }} | ||
| if [ -z "$PR_COMMITS" ]; then | ||
| echo "Not a PR event. Using default fetch_depth of 1" | ||
| RESULT=1 | ||
| else | ||
| echo "PR event detected with $PR_COMMITS commits" | ||
| REQUIRED_DEPTH=$((PR_COMMITS + 1)) | ||
| fi | ||
| echo "depth=$REQUIRED_DEPTH" >> $GITHUB_OUTPUT | ||
| validate-semantic-commits: | ||
| name: Validate semantic commits | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| fetch-depth: ${{ github.event.pull_request.commits + 1 }} | ||
| - name: Validate commit messages | ||
| uses: webiny/action-conventional-commits@7f91b1595ca1951cdb671ddc9f07a49081ec5b69 # v1.4.2 | ||