Skip to content

Commit

Permalink
fix: escape variables in update step
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed Feb 25, 2024
1 parent b8c9cf0 commit ec779dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
UPDATED: ${{ steps.python.outputs.UPDATED }}
UPDATED: ${{ steps.updated.outputs.UPDATED }}

steps:
- name: Checkout
Expand All @@ -21,20 +21,22 @@ jobs:
version=$(npm view @ast-grep/cli version)
version_check='^[0-9]+\.[0-9]+\.[0-9]+$'
if [[ $version =~ $version_check ]]; then
if [[ "${version}" =~ $version_check ]]; then
echo "VERSION=${version}" >> $GITHUB_OUTPUT
else
echo "::error::Invalid package version: '$version'"
exit 1
fi
- name: Update version
id: python
- name: Set version
id: updated
shell: python
env:
VERSION: "${{ steps.version.outputs.VERSION }}"
run: |
import pathlib, re, os
npm_version = "${{ steps.version.outputs.VERSION }}"
npm_version = os.environ["VERSION"]
config = pathlib.Path(".pre-commit-hooks.yaml").read_text()
match = re.search(r'"@ast-grep/cli@([^\"]+)"', config)
Expand All @@ -47,11 +49,14 @@ jobs:
update-update:
runs-on: ubuntu-latest
needs: ["check-version"]
if: ${{ needs.check-version.outputs.UPDATED == 'true' }}
if: ${{ needs.check-version.outputs.UPDATED == 'true' }}

permissions:
contents: write

env:
VERSION: "${{ needs.check-version.outputs.VERSION }}"

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
Expand All @@ -61,7 +66,7 @@ jobs:
run: |
import pathlib, re, os
version = "${{ needs.check-version.outputs.VERSION }}"
version = os.environ["VERSION"]
config = pathlib.Path(".pre-commit-hooks.yaml")
readme = pathlib.Path("README.md")
Expand All @@ -78,6 +83,6 @@ jobs:
git config user.name github-actions
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git commit -am "chore: update version ${{ needs.check-version.outputs.VERSION }}"
git tag "${{ needs.check-version.outputs.VERSION }}"
git commit -am "chore: update version ${VERSION}"
git tag "${VERSION}"
git push --tags origin main
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Note that only rules with a severity of "error" will lead to the commit hook fai
args: ["--update-all"]
```

When executing rewrites, the commit hook will fail for any severity.


### Provide explicit configuration

Expand Down

0 comments on commit ec779dc

Please sign in to comment.