Skip to content

Commit 0e42752

Browse files
ci: scope permissions to job level (#202)
1 parent bdd4e33 commit 0e42752

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: CI
3-
permissions:
4-
contents: read
3+
permissions: {}
54

65
on:
76
pull_request:
@@ -45,6 +44,8 @@ jobs:
4544
build:
4645
name: Build
4746
needs: setup_release
47+
permissions:
48+
contents: read
4849
runs-on: ${{ matrix.os }}
4950
defaults:
5051
run:
@@ -166,17 +167,19 @@ jobs:
166167

167168
- name: Python Path
168169
id: python-path
170+
env:
171+
TMP_PYTHON_PATH: ${{ steps.setup-python.outputs.python-path }}
169172
run: |
170-
if [ "${{ runner.os }}" == "Windows" ]; then
173+
if [ "${RUNNER_OS}" == "Windows" ]; then
171174
# replace backslashes with double backslashes
172-
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
175+
python_path=$(echo "${TMP_PYTHON_PATH}" | sed 's/\\/\\\\/g')
173176
else
174-
python_path="${{ steps.setup-python.outputs.python-path }}"
177+
python_path="${TMP_PYTHON_PATH}"
175178
fi
176179
177180
# step output
178181
echo "python-path=${python_path}"
179-
echo "python-path=${python_path}" >> $GITHUB_OUTPUT
182+
echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}"
180183
181184
- name: Build
182185
env:
@@ -186,7 +189,7 @@ jobs:
186189
run: |
187190
mkdir -p build
188191
189-
if [ "${{ runner.os }}" = "Linux" ]; then
192+
if [ "${RUNNER_OS}" = "Linux" ]; then
190193
# Doxygen from Ubuntu is too old, need Doxygen >= 1.10
191194
DOCS=OFF
192195
else
@@ -212,10 +215,12 @@ jobs:
212215
if: >-
213216
always() &&
214217
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
218+
env:
219+
PYTHON_PATH: ${{ steps.python-path.outputs.python-path }}
215220
working-directory: build
216221
run: |
217-
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
218-
${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \
222+
"${PYTHON_PATH}" -m pip install gcovr
223+
"${PYTHON_PATH}" -m gcovr . -r ../src \
219224
--exclude-noncode-lines \
220225
--exclude-throw-branches \
221226
--exclude-unreachable-branches \
@@ -238,7 +243,7 @@ jobs:
238243
- name: Move Artifacts
239244
run: |
240245
mkdir -p artifacts
241-
if ["${{ runner.os }}" == "Windows"]; then
246+
if ["${RUNNER_OS}" == "Windows"]; then
242247
mv -f ./build/tests/test_libdisplaydevice.exe artifacts/
243248
else
244249
mv -f ./build/tests/test_libdisplaydevice artifacts/
@@ -258,6 +263,8 @@ jobs:
258263
(needs.build.result == 'success' || needs.build.result == 'failure') &&
259264
startsWith(github.repository, 'LizardByte/')
260265
needs: build
266+
permissions:
267+
contents: read
261268
runs-on: ubuntu-latest
262269
strategy:
263270
fail-fast: false
@@ -314,6 +321,8 @@ jobs:
314321
needs:
315322
- build
316323
- setup_release
324+
permissions:
325+
contents: read
317326
runs-on: ubuntu-latest
318327
steps:
319328
- name: Download build artifact (Windows)

0 commit comments

Comments
 (0)