build(deps): bump the cargo group across 1 directory with 3 updates #90
This file contains 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
name: Handle dependency updates | |
on: | |
pull_request: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
if: github.actor == 'dependabot[bot]' | |
steps: | |
- name: Fetch dependabot metadata | |
id: metadata | |
uses: dependabot/fetch-metadata@v2 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
if: steps.metadata.outputs.package-ecosystem == 'npm_and_yarn' | |
with: | |
ref: ${{github.head_ref}} | |
- name: Regenerate parser | |
if: steps.metadata.outputs.package-ecosystem == 'npm_and_yarn' | |
run: |- | |
npm ci --legacy-peer-deps | |
npm x -- tree-sitter generate --no-bindings | |
- name: Update scanner | |
if: steps.metadata.outputs.package-ecosystem == 'npm_and_yarn' | |
run: |- | |
language=$(jq -r .name src/grammar.json) | |
parent=$(gh api --jq '.[]|select(.property_name == "Inherits")|.value' $API_ENDPOINT) | |
sed "s/tree_sitter_${parent}_/tree_sitter_${language}_/" \ | |
"node_modules/tree-sitter-${parent}/src/scanner.c" > src/scanner.c | |
env: | |
GH_TOKEN: ${{github.token}} | |
API_ENDPOINT: repos/${{github.repository}}/properties/values | |
- name: Commit changes | |
if: steps.metadata.outputs.package-ecosystem == 'npm_and_yarn' | |
run: |- | |
if ! git diff --quiet -- src && git add src; then | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
git commit -m 'build: regenerate parser [dependabot skip]' | |
git push origin HEAD:$GITHUB_HEAD_REF | |
fi |