Skip to content

Commit 00675d0

Browse files
ci: Quote Bash and YAML variables in workflows
Prevent strings that should be interpreted literally from being interpreted as keywords, operators, etc. Also, consistently style GitHub Actions expressions with spaces separating curly braces from variables.
1 parent 51af48e commit 00675d0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

.github/workflows/bumpversion.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- name: Create bump and changelog
1818
uses: commitizen-tools/commitizen-action@master
1919
with:
20-
github_token: ${{ secrets.GITHUB_TOKEN }}
20+
github_token: "${{ secrets.GITHUB_TOKEN }}"
2121
changelog_increment_filename: body.md
2222
- name: Release
2323
uses: softprops/action-gh-release@v1
2424
with:
2525
body_path: "body.md"
26-
tag_name: ${{ env.REVISION }}
26+
tag_name: "${{ env.REVISION }}"
2727
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/test_action.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212
with:
13-
ref: ${{github.event.pull_request.head.ref}}
14-
repository: ${{github.event.pull_request.head.repo.full_name}}
13+
ref: "${{ github.event.pull_request.head.ref }}"
14+
repository: "${{ github.event.pull_request.head.repo.full_name }}"
1515
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
1616
- name: Capture commit id
1717
id: capture
1818
run: |
19-
COMMIT_ID=$(git rev-parse ${{ github.head_ref }})
19+
COMMIT_ID="$(git rev-parse "${{ github.head_ref }}")"
2020
echo "The sha of the starting commit is $COMMIT_ID"
2121
echo "::set-output name=commit::$COMMIT_ID"
2222
- name: create test commit
@@ -29,27 +29,27 @@ jobs:
2929
- name: test action
3030
uses: ./
3131
with:
32-
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
github_token: "${{ secrets.GITHUB_TOKEN }}"
3333
commit: false
3434
push: false
3535
- uses: actions/checkout@v2
3636
with:
37-
ref: ${{github.event.pull_request.head.ref}}
38-
repository: ${{github.event.pull_request.head.repo.full_name}}
37+
ref: "${{ github.event.pull_request.head.ref }}"
38+
repository: "${{ github.event.pull_request.head.repo.full_name }}"
3939
fetch-depth: 0 # ensures that tags are fetched, seems to be needed
4040
path: new_head
4141
- name: Test push
4242
run: |
4343
cd new_head
44-
last_pushed_commit=$(git rev-parse ${{ github.head_ref }})
44+
last_pushed_commit="$(git rev-parse "${{ github.head_ref }}")"
4545
echo "Commit sha on origin: $last_pushed_commit"
46-
if [[ $last_pushed_commit != ${{steps.capture.outputs.commit}} ]]; then
46+
if [[ $last_pushed_commit != ${{ steps.capture.outputs.commit }} ]]; then
4747
echo "Something got pushed to ${{ github.head_ref }}"
4848
exit 1
4949
fi
5050
- name: Test commit
5151
run: |
52-
commit_message=$(git log -1 HEAD --pretty=format:%s)
52+
commit_message="$(git log -1 HEAD --pretty=format:%s)"
5353
echo "Latest commit: $commit_message"
5454
if [[ $commit_message != "feat: test feature" ]]; then
5555
echo "The latest commit message is not 'feat: test feature'"

0 commit comments

Comments
 (0)