Skip to content

Commit c2073b0

Browse files
committed
fix(actions): Harden workflows when using variables in strings
Signed-off-by: Joas Schilling <[email protected]>
1 parent 3237123 commit c2073b0

22 files changed

Lines changed: 78 additions & 87 deletions

.github/workflows/block-merge-eol.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ jobs:
2626
runs-on: ubuntu-latest-low
2727

2828
steps:
29-
- name: Download updater config
30-
run: curl https://raw.githubusercontent.com/nextcloud/updater_server/production/config/config.php --output config.php
31-
3229
- name: Set server major version environment
3330
run: |
3431
# retrieve version number from branch reference
3532
server_major=$(echo "${{ github.base_ref }}" | sed -En 's/stable//p')
3633
echo "server_major=$server_major" >> $GITHUB_ENV
34+
echo "current_month=$(date +%Y-%m)" >> $GITHUB_ENV
3735
3836
- name: Checking if ${{ env.server_major }} is EOL
3937
run: |
40-
php -r 'echo json_encode(require_once "config.php");' | jq --arg version "${{ env.server_major }}" '.stable[$version]["100"].eol // .beta[$version]["100"].eol // "NotEOL"' | grep -q "NotEOL"
38+
curl -s https://raw.githubusercontent.com/nextcloud-releases/updater_server/production/config/major_versions.json \
39+
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99" | . >= "${{ env.current_month }}"' \
40+
| grep -q true

.github/workflows/block-merge-freeze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: Download version.php from ${{ github.base_ref }}
32-
run: curl https://raw.githubusercontent.com/nextcloud/server/${{ github.base_ref }}/version.php --output version.php
32+
run: curl 'https://raw.githubusercontent.com/nextcloud/server/${{ github.base_ref }}/version.php' --output version.php
3333

3434
- name: Run check
3535
run: cat version.php | grep 'OC_VersionString' | grep -i -v 'RC'

.github/workflows/block-outdated-3rdparty.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ jobs:
4646
- name: Compare if 3rdparty commits are different
4747
run: |
4848
echo '3rdparty/ seems to not point to the last commit of the dedicated branch:'
49-
echo "Branch has: ${{ steps.actual.outputs.commit }}"
50-
echo "${{ github.base_ref }} has: ${{ steps.target.outputs.commit }}"
49+
echo 'Branch has: ${{ steps.actual.outputs.commit }}'
50+
echo '${{ github.base_ref }} has: ${{ steps.target.outputs.commit }}'
5151
5252
- name: Fail if 3rdparty commits are different
5353
if: ${{ steps.changes.outputs.src != 'false' && steps.actual.outputs.commit != steps.target.outputs.commit }}

.github/workflows/command-compile.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
token: ${{ secrets.COMMAND_BOT_PAT }}
3838
repository: ${{ github.event.repository.full_name }}
3939
comment-id: ${{ github.event.comment.id }}
40-
reactions: "+1"
40+
reactions: '+1'
4141

4242
- name: Parse command
4343
uses: skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
@@ -77,8 +77,8 @@ jobs:
7777

7878
- name: Setup git
7979
run: |
80-
git config --local user.email "[email protected]"
81-
git config --local user.name "nextcloud-command"
80+
git config --local user.email '[email protected]'
81+
git config --local user.name 'nextcloud-command'
8282
8383
- name: Read package.json node and npm engines version
8484
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
@@ -94,13 +94,13 @@ jobs:
9494
cache: npm
9595

9696
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
97-
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
97+
run: npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
9898

9999
- name: Rebase to ${{ needs.init.outputs.base_ref }}
100100
if: ${{ contains(needs.init.outputs.arg1, 'rebase') }}
101101
run: |
102-
git fetch origin ${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}
103-
git rebase origin/${{ needs.init.outputs.base_ref }}
102+
git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
103+
git rebase 'origin/${{ needs.init.outputs.base_ref }}'
104104
105105
- name: Install dependencies & build
106106
env:
@@ -113,30 +113,30 @@ jobs:
113113
- name: Commit default
114114
if: ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
115115
run: |
116-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
116+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
117117
git commit --signoff -m 'chore(assets): Recompile assets'
118118
119119
- name: Commit fixup
120120
if: ${{ contains(needs.init.outputs.arg1, 'fixup') }}
121121
run: |
122-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
122+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
123123
git commit --fixup=HEAD --signoff
124124
125125
- name: Commit amend
126126
if: ${{ contains(needs.init.outputs.arg1, 'amend') }}
127127
run: |
128-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
128+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
129129
git commit --amend --no-edit --signoff
130130
# Remove any [skip ci] from the amended commit
131131
git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
132132
133133
- name: Push normally
134134
if: ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
135-
run: git push origin ${{ needs.init.outputs.head_ref }}
135+
run: git push origin '${{ needs.init.outputs.head_ref }}'
136136

137137
- name: Force push
138138
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
139-
run: git push --force origin ${{ needs.init.outputs.head_ref }}
139+
run: git push --force origin '${{ needs.init.outputs.head_ref }}'
140140

141141
- name: Add reaction on failure
142142
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0

.github/workflows/command-pull-3rdparty.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
token: ${{ secrets.COMMAND_BOT_PAT }}
2626
repository: ${{ github.event.repository.full_name }}
2727
comment-id: ${{ github.event.comment.id }}
28-
reactions: "+1"
28+
reactions: '+1'
2929

3030
- name: Init branch
3131
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
@@ -40,16 +40,16 @@ jobs:
4040

4141
- name: Setup git
4242
run: |
43-
git config --local user.email "[email protected]"
44-
git config --local user.name "nextcloud-command"
43+
git config --local user.email '[email protected]'
44+
git config --local user.name 'nextcloud-command'
4545
4646
- name: Pull 3rdparty
47-
run: git submodule foreach 'if [ "$sm_path" == "3rdparty" ]; then git pull origin ${{ github.event.issue.pull_request.base.ref }}; fi'
47+
run: git submodule foreach 'if [ "$sm_path" == "3rdparty" ]; then git pull origin '"'"'${{ github.event.issue.pull_request.base.ref }}'"'"'; fi'
4848

4949
- name: Commit and push changes
5050
run: |
5151
git add 3rdparty
52-
git commit -s -m "Update submodule 3rdparty to latest ${{ github.event.issue.pull_request.base.ref }}"
52+
git commit -s -m 'Update submodule 3rdparty to latest ${{ github.event.issue.pull_request.base.ref }}'
5353
git push
5454
5555
- name: Add reaction on failure
@@ -59,4 +59,4 @@ jobs:
5959
token: ${{ secrets.COMMAND_BOT_PAT }}
6060
repository: ${{ github.event.repository.full_name }}
6161
comment-id: ${{ github.event.comment.id }}
62-
reactions: "-1"
62+
reactions: '-1'

.github/workflows/cypress.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ concurrency:
1717
env:
1818
# Adjust APP_NAME if your repository name is different
1919
APP_NAME: ${{ github.event.repository.name }}
20+
2021
# Server requires head_ref instead of base_ref, as we want to test the PR branch
2122
BRANCH: ${{ github.head_ref || github.ref_name }}
2223

@@ -52,15 +53,15 @@ jobs:
5253
id: versions
5354
with:
5455
fallbackNode: "^20"
55-
fallbackNpm: "^9"
56+
fallbackNpm: "^10"
5657

5758
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
5859
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
5960
with:
6061
node-version: ${{ steps.versions.outputs.nodeVersion }}
6162

6263
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
63-
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
64+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
6465

6566
- name: Install node dependencies & build app
6667
run: |
@@ -85,9 +86,9 @@ jobs:
8586
matrix:
8687
# Run multiple copies of the current job in parallel
8788
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
88-
containers: ["component", 0, 1, 2, 3, 4, 5]
89+
containers: ["component", '0', '1', '2', '3', '4', '5']
8990
# Hack as strategy.job-total includes the component and GitHub does not allow math expressions
90-
# Always aling this number with the total of e2e runners (max. index + 1)
91+
# Always align this number with the total of e2e runners (max. index + 1)
9192
total-containers: [6]
9293

9394
name: runner ${{ matrix.containers }}
@@ -106,7 +107,7 @@ jobs:
106107
node-version: ${{ needs.init.outputs.nodeVersion }}
107108

108109
- name: Set up npm ${{ needs.init.outputs.npmVersion }}
109-
run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
110+
run: npm i -g 'npm@${{ needs.init.outputs.npmVersion }}'
110111

111112
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
112113
uses: cypress-io/github-action@f88a151c986cab2e339cdbede6a5c4468bb62c17 # v6.7.0

.github/workflows/dependabot-approve-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
pull-requests: write
3232

3333
steps:
34-
# Github actions bot approve
34+
# GitHub actions bot approve
3535
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
3636
with:
3737
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/files-external-s3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
MINIO_ROOT_PASSWORD: bWluaW8tc2VjcmV0LWtleS1uZXh0Y2xvdWQ=
5757
MINIO_DEFAULT_BUCKETS: nextcloud
5858
ports:
59-
- "9000:9000"
59+
- '9000:9000'
6060

6161
steps:
6262
- name: Checkout server

.github/workflows/files-external-sftp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
sudo mkdir /tmp/sftp
6363
sudo chown -R 0777 /tmp/sftp
64-
if [[ "${{ matrix.sftpd }}" == 'openssh' ]]; then docker run -p 2222:22 --name sftp -d -v /tmp/sftp:/home/test atmoz/sftp "test:test:::data"; fi
64+
if [[ '${{ matrix.sftpd }}' == 'openssh' ]]; then docker run -p 2222:22 --name sftp -d -v /tmp/sftp:/home/test atmoz/sftp 'test:test:::data'; fi
6565
6666
- name: Set up php ${{ matrix.php-versions }}
6767
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d #v2.25.2

.github/workflows/lint-eslint.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
name: Lint eslint
1010

11-
on:
12-
pull_request:
11+
on: pull_request
1312

1413
permissions:
1514
contents: read
@@ -61,15 +60,15 @@ jobs:
6160
id: versions
6261
with:
6362
fallbackNode: '^20'
64-
fallbackNpm: '^9'
63+
fallbackNpm: '^10'
6564

6665
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
67-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
66+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
6867
with:
6968
node-version: ${{ steps.versions.outputs.nodeVersion }}
7069

7170
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
72-
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
71+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
7372

7473
- name: Install dependencies
7574
env:

0 commit comments

Comments
 (0)