|
5 | 5 | push:
|
6 | 6 | # Selected branches
|
7 | 7 | branches: [develop, master, docs, patch]
|
| 8 | + # Runs on creating a new tag starting with 'v', e.g. 'v1.0.3' |
| 9 | + tags: |
| 10 | + - 'v*' |
8 | 11 | # Allows you to run this workflow manually from the Actions tab
|
9 | 12 | workflow_dispatch:
|
10 | 13 |
|
@@ -160,10 +163,10 @@ jobs:
|
160 | 163 | path: site/
|
161 | 164 |
|
162 | 165 | # Upload the static files from the site/ directory to be used in the next job
|
163 |
| - # This extra step is needed to allow the download of the artifact in the next job |
164 |
| - # for pushing its content to the branch named 'gh_pages' |
165 |
| - - name: Upload built site as artifact for gh_pages (master branch) |
166 |
| - if: ${{ env.CI_BRANCH == 'master' }} |
| 166 | + # This artifact is only uploaded on tagged releases (tags starting with 'v', e.g., v1.0.3) |
| 167 | + # and is used to push content to gh_pages for custom domain deployment. |
| 168 | + - name: Upload built site as artifact for gh_pages (tagged release) |
| 169 | + if: startsWith(github.ref, 'refs/tags/v') |
167 | 170 | uses: actions/upload-artifact@v4
|
168 | 171 | with:
|
169 | 172 | name: artifact # name of the artifact (without the extension zip)
|
@@ -206,26 +209,30 @@ jobs:
|
206 | 209 | (all branches)
|
207 | 210 | uses: actions/deploy-pages@v4
|
208 | 211 |
|
209 |
| - # Download built site as artifact from a previous job for gh_pages (master branch) |
210 |
| - - name: Download built site from previous job (master branch) |
211 |
| - if: ${{ env.CI_BRANCH == 'master' }} |
| 212 | + # Download built site as artifact from a previous job for gh_pages (tagged release) |
| 213 | + # This artifact is only downloaded on tagged releases (tags starting with 'v', e.g., v1.0.3) |
| 214 | + # and is used to push content to gh_pages for custom domain deployment. |
| 215 | + - name: Download built site from previous job (tagged release) |
| 216 | + if: startsWith(github.ref, 'refs/tags/v') |
212 | 217 | uses: actions/download-artifact@v4
|
213 | 218 | with: # name or path are taken from the upload step of the previous job
|
214 | 219 | name: artifact
|
215 | 220 | path: site/ # directory to extract downloaded zipped artifacts
|
216 | 221 |
|
217 | 222 | # Push the site files created in the previous job to the gh_pages branch
|
| 223 | + # This push happens only for tagged releases (tags starting with 'v'), |
| 224 | + # which triggers deployment to the custom domain via webhook. |
| 225 | + # |
218 | 226 | # To be able to push to the gh_pages branch, the personal GitHub API access
|
219 | 227 | # token GH_API_PERSONAL_ACCSESS_TOKEN must be set for this repository via
|
220 | 228 | # https://github.com/easyscience/diffraction-lib/settings/secrets/actions
|
221 |
| - # This branch is used to deploy the site to the custom domain. |
222 |
| - # Deploying is done with a webhook: |
| 229 | + # Then the gh_pages branch is used to deploy the site to the custom domain. |
| 230 | + # Deploying is done with a webhook added via: |
223 | 231 | # https://github.com/easyscience/diffraction-lib/settings/hooks
|
224 |
| - # This is done for the gh_pages branch when the site is tested with a step above |
225 | 232 | - name:
|
226 | 233 | Deploy to gh_pages branch to trigger deployment to custom domain
|
227 |
| - (master branch) |
228 |
| - if: ${{ env.CI_BRANCH == 'master' }} |
| 234 | + (tagged release) |
| 235 | + if: startsWith(github.ref, 'refs/tags/v') |
229 | 236 | uses: s0/git-publish-subdir-action@develop
|
230 | 237 | env:
|
231 | 238 | GITHUB_TOKEN: ${{ secrets.GH_API_PERSONAL_ACCSESS_TOKEN }}
|
|
0 commit comments