Skip to content

Commit 7fa63b2

Browse files
ci: Avoid overly broad permissions for workflow jobs - Add specific ones for those using secrets
1 parent b4e471d commit 7fa63b2

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

.github/workflows/cicd.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ env:
1414
MAIN_PYTHON_VERSION: 3.13
1515
DOCUMENTATION_CNAME: tools.docs.pyansys.com
1616

17+
permissions: {} # Disable default permissions
18+
1719
jobs:
1820

1921
update-changelog:
@@ -34,31 +36,34 @@ jobs:
3436
# check-vulnerabilities:
3537
# name: "Check library vulnerabilities"
3638
# runs-on: ubuntu-latest
39+
# permissions:
40+
# contents: read
3741
# steps:
38-
# - uses: ansys/actions/check-vulnerabilities@v10.0
42+
# - uses: ansys/actions/check-vulnerabilities@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
3943
# with:
4044
# python-version: ${{ env.MAIN_PYTHON_VERSION }}
4145
# token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
4246
# python-package-name: ${{ env.PACKAGE_NAME }}
4347
# dev-mode: ${{ github.ref != 'refs/heads/main' }}
4448

4549
style:
46-
name: Code style
47-
runs-on: ubuntu-latest
48-
steps:
49-
- name: PyAnsys code style checks
50-
uses: ansys/actions/code-style@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
51-
with:
52-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
50+
name: Code style
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: PyAnsys code style checks
54+
uses: ansys/actions/code-style@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
55+
with:
56+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
57+
5358
smoke-tests:
54-
name: Build and Smoke tests
55-
runs-on: ${{ matrix.os }}
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
os: [ubuntu-latest, windows-latest, macos-latest]
60-
python-version: ['3.10', '3.11', '3.12']
61-
steps:
59+
name: Build and Smoke tests
60+
runs-on: ${{ matrix.os }}
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
os: [ubuntu-latest, windows-latest, macos-latest]
65+
python-version: ['3.10', '3.11', '3.12']
66+
steps:
6267
- name: Build wheelhouse and perform smoke test
6368
uses: ansys/actions/build-wheelhouse@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
6469
with:
@@ -71,6 +76,8 @@ jobs:
7176
name: Testing
7277
runs-on: ubuntu-latest
7378
needs: [smoke-tests]
79+
permissions:
80+
contents: read
7481
env:
7582
ANSYS_LOCAL: false
7683
ON_UBUNTU: true
@@ -99,14 +106,16 @@ jobs:
99106
uv pip install tests/launcher/pkg_with_entrypoint
100107
uv run pytest
101108
102-
# - uses: codecov/codecov-action@v5
109+
# - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
103110
# name: 'Upload coverage to CodeCov'
104111
# with:
105112
# token: ${{ secrets.CODECOV_TOKEN }}
106113

107114
docs-style:
108115
name: Documentation Style Check
109116
runs-on: ubuntu-latest
117+
permissions:
118+
contents: read
110119
steps:
111120
- name: PyAnsys documentation style checks
112121
uses: ansys/actions/doc-style@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4
@@ -178,6 +187,8 @@ jobs:
178187
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
179188
runs-on: ubuntu-latest
180189
needs: [release]
190+
permissions:
191+
contents: write
181192
steps:
182193
- name: Deploy the stable documentation
183194
uses: ansys/actions/doc-deploy-stable@c2fa7c93f6883114e0e643599431b33d29f0b13f # v10.1.4

.github/workflows/label.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions: {} # Disable default permissions
18+
1719
jobs:
1820

1921
label-syncer:

.github/workflows/run_mapdl_tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ env:
1313
PACKAGE_NAME: ansys-tools-common
1414
MAIN_PYTHON_VERSION: 3.13
1515

16+
permissions:
17+
contents: read
18+
packages: read
19+
1620
jobs:
1721
build-tests:
1822
name: Build tests
@@ -50,7 +54,7 @@ jobs:
5054
uv pip install tests/launcher/pkg_with_entrypoint
5155
uv run pytest -vx --cov=${PACKAGE_NAMESPACE} --cov-report=term --cov-report=xml:.cov/coverage.xml --cov-report=html:.cov/html
5256
53-
# - uses: codecov/codecov-action@v5
57+
# - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
5458
# name: 'Upload coverage to CodeCov'
5559
# with:
5660
# token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)