@@ -48,21 +48,9 @@ name: sphinx
4848
4949on :
5050 pull_request :
51- paths :
52- - ' .github/actions/sphinx/**'
53- - ' .github/workflows/sphinx.yml'
54- - ' examples/**'
55- - ' sphinx/**'
56- - ' skore/**'
5751 push :
5852 branches :
5953 - main
60- paths :
61- - ' .github/actions/sphinx/**'
62- - ' .github/workflows/sphinx.yml'
63- - ' examples/**'
64- - ' sphinx/**'
65- - ' skore/**'
6654 release :
6755 types : [released]
6856 merge_group :
@@ -72,9 +60,35 @@ concurrency:
7260 group : ${{ github.workflow }}-${{ github.ref }}
7361 cancel-in-progress : true
7462
63+ permissions : {}
64+
7565jobs :
66+ sphinx-changes :
67+ runs-on : ubuntu-latest
68+ outputs :
69+ changes : ${{ steps.filter.outputs.sphinx }}
70+ permissions :
71+ pull-requests : read
72+ steps :
73+ - name : Checkout code
74+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
76+ - name : Define if at least one file has changed
77+ uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
78+ id : filter
79+ with :
80+ filters : |
81+ sphinx:
82+ - '.github/actions/sphinx/**'
83+ - '.github/workflows/sphinx.yml'
84+ - 'examples/**'
85+ - 'sphinx/**'
86+ - 'skore/**'
87+
7688 sphinx-version :
7789 runs-on : ubuntu-latest
90+ needs : [sphinx-changes]
91+ if : ${{ (contains(fromJSON('["push", "release"]'), github.event_name)) || (needs.sphinx-changes.outputs.changes == 'true') }}
7892 outputs :
7993 SPHINX_VERSION : ${{ steps.sphinx-version.outputs.SPHINX_VERSION }}
8094 SPHINX_RELEASE : ${{ steps.sphinx-version.outputs.SPHINX_RELEASE }}
@@ -99,12 +113,15 @@ jobs:
99113
100114 sphinx-build :
101115 runs-on : ubuntu-latest
102- needs : sphinx-version
116+ needs : [sphinx-version]
117+ if : ${{ (contains(fromJSON('["push", "release"]'), github.event_name)) || (needs.sphinx-changes.outputs.changes == 'true') }}
118+ permissions :
119+ contents : read
103120 steps :
104- - uses : actions/checkout@v4
121+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
105122 with :
106123 lfs : ' true'
107- - uses : actions/setup-python@v5
124+ - uses : actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
108125 with :
109126 python-version : ' 3.12'
110127 cache : ' pip'
@@ -114,21 +131,25 @@ jobs:
114131 SPHINX_VERSION : ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
115132 SPHINX_RELEASE : ${{ needs.sphinx-version.outputs.SPHINX_RELEASE }}
116133 SPHINX_DOMAIN : ${{ vars.DOCUMENTATION_DOMAIN }}
117- - uses : actions/upload-artifact@v4
134+ - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
118135 with :
119136 name : sphinx-html-artifact
120137 path : sphinx/build/html/
121138
122139 sphinx-deploy-html :
123- if : ${{ (github.event_name == ' release') || ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) }}
140+ if : ${{ (contains(fromJSON('["push", " release"]'), github.event_name) ) }}
124141 runs-on : ubuntu-latest
125142 needs : [sphinx-version, sphinx-build]
143+ permissions :
144+ contents : read
126145 steps :
127146 - name : Checkout code
128- uses : actions/checkout@v4
147+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
148+ with :
149+ sparse-checkout : .github
129150
130151 - name : Download HTML artifacts
131- uses : actions/download-artifact@v4
152+ uses : actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
132153 with :
133154 name : sphinx-html-artifact
134155 path : html/
@@ -145,8 +166,12 @@ jobs:
145166 if : ${{ github.event_name == 'release' }}
146167 runs-on : ubuntu-latest
147168 needs : [sphinx-version, sphinx-build, sphinx-deploy-html]
169+ permissions :
170+ contents : read
148171 steps :
149- - uses : actions/checkout@v4
172+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
173+ with :
174+ sparse-checkout : .github
150175 - shell : python
151176 run : |
152177 import os
@@ -239,6 +264,21 @@ jobs:
239264 if : ${{ always() && (github.event_name != 'pull_request') }}
240265 needs : [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
241266 steps :
242- - uses : geekyeggo/delete-artifact@v5
267+ - uses : geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
243268 with :
244269 name : sphinx-html-artifact
270+
271+ sphinx :
272+ needs :
273+ - sphinx-changes
274+ - sphinx-version
275+ - sphinx-build
276+ - sphinx-deploy-html
277+ - sphinx-deploy-root-files
278+ - sphinx-clean-artifacts
279+ if : ${{ always() }}
280+ runs-on : Ubuntu-latest
281+ steps :
282+ - shell : bash
283+ run : |
284+ [[ ${{ contains(needs.*.result, 'failure') }} = false ]]
0 commit comments