Skip to content

Commit

Permalink
Merge pull request #674 from weseek/fix/ensure-that-input-string-do-n…
Browse files Browse the repository at this point in the history
…ot-afect-commands

fix: Ensure that input string do not afect commands
  • Loading branch information
ryu-sato authored Jul 20, 2024
2 parents c088454 + e4d7dfb commit f451dea
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/misc-command-bump_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ jobs:
if: >
contains( github.event.comment.html_url, '/pull/' )
&& startsWith( github.event.comment.body, '/bump-version ' )
&& github.head_ref == 'next-version'
steps:
- name: Get metadata
id: meta
run: |
# Get up range from comment (one of ["patch","minor","major"])
UP_RANGE=$(echo ${{ github.event.comment.body }} | sed -e 's/\/bump-version [[:space:]]*\(.*\)/\1/')
bash -c "[[ ${UP_RANGE} =~ (patch|minor|major) ]]"
echo "::set-output name=up_range::${UP_RANGE}"
# Get ref branch
echo "::set-output name=branch_name::$(curl -H \"Authorization: token ${GITHUB_TOKEN}\" ${{ github.event.issue.pull_request.url }} | jq -r '.head.ref')"
- name: Set up range to 'patch'
if: github.event.comment.body == '/bump-version patch'
run: echo "UP_RANGE=patch" >> $GITHUB_ENV
- name: Set up range to 'minor'
if: github.event.comment.body == '/bump-version minor'
run: echo "UP_RANGE=minor" >> $GITHUB_ENV
- name: Set up range to 'major'
if: github.event.comment.body == '/bump-version major'
run: echo "UP_RANGE=major" >> $GITHUB_ENV
- name: Check up range
if: >
! contains(fromJSON('["patch", "minor", "major"]'), env.UP_RANGE)
run: echo 'invalid up range'; exit 1
- uses: actions/checkout@v4
with:
ref: ${{ steps.meta.outputs.branch_name }}
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version: "16.14.2"
Expand All @@ -38,7 +40,7 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com
yarn run "bump-version:${{ steps.meta.outputs.up_range }}"
yarn run "bump-version:${UP_RANGE}"
git commit -am 'Bump up version'
git push
Expand Down

0 comments on commit f451dea

Please sign in to comment.