Skip to content

ci: fetch only the number of commits needed for checks #2

ci: fetch only the number of commits needed for checks

ci: fetch only the number of commits needed for checks #2

on:

Check failure on line 1 in .github/workflows/semantic-git-message.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/semantic-git-message.yml

Invalid workflow file

(Line: 38, Col: 24): Unexpected symbol: '+'. Located at position 35 within expression: github.event.pull_request.commits + 1
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