Skip to content

Commit bb10eb7

Browse files
committed
Update build.yaml workflow
1 parent 29ca32b commit bb10eb7

1 file changed

Lines changed: 86 additions & 38 deletions

File tree

.github/workflows/build.yaml

Lines changed: 86 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ on:
1414
required: false
1515
default: ""
1616

17-
defaults:
18-
run:
19-
shell: bash -leo pipefail {0} {0}
20-
21-
2217
jobs:
2318

2419
find-tag:
@@ -40,12 +35,12 @@ jobs:
4035
steps:
4136
- uses: actions/checkout@v4
4237

43-
- name: Install mamba
44-
uses: mamba-org/setup-micromamba@v1
38+
- uses: prefix-dev/setup-pixi@v0.4.1
4539
with:
46-
environment-file: environment.yaml
47-
48-
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
40+
cache: true
41+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
42+
43+
- run: pixi run sphinx-build -M linkcheck . _build -W --keep-going -a -q
4944

5045

5146
link-check-last-tagged:
@@ -57,15 +52,30 @@ jobs:
5752
with:
5853
ref: ${{ needs.find-tag.outputs.latest-tag }}
5954

55+
- uses: prefix-dev/setup-pixi@v0.4.1
56+
continue-on-error: true
57+
id: pixisetup
58+
with:
59+
cache: true
60+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
61+
62+
- if: steps.pixisetup.outcome == 'success'
63+
run: pixi sphinx-build -M linkcheck . _build -W --keep-going -a -q
64+
6065
- name: Install mamba
66+
if: steps.pixisetup.outcome == 'failure'
6167
uses: mamba-org/setup-micromamba@v1
6268
with:
6369
environment-file: environment.yaml
70+
71+
- name: build with mamba
72+
if: steps.pixisetup.outcome == 'failure'
73+
shell: bash -leo pipefail {0} {0}
74+
run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
75+
6476

65-
- run: sphinx-build -M linkcheck . _build -W --keep-going -a -q
66-
6777

68-
build:
78+
build-latest:
6979

7080
runs-on: ubuntu-latest
7181
needs: [find-tag, link-check]
@@ -75,41 +85,80 @@ jobs:
7585
with:
7686
fetch-depth: 0
7787

78-
- name: Install mamba
79-
uses: mamba-org/setup-micromamba@v1
88+
- uses: prefix-dev/setup-pixi@v0.4.1
8089
with:
81-
environment-file: environment.yaml
82-
90+
cache: true
91+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
92+
8393
- name: Build Documentation
84-
run: |
85-
sphinx-build -M html . _build-beta -W --keep-going -a -t draft
94+
run: pixi run sphinx-build -M html . _build -W --keep-going -a -t draft
8695

87-
- name: Checkout last tagged
88-
run: |
89-
git checkout ${{ needs.find-tag.outputs.latest-tag }}
96+
- uses: actions/upload-artifact@v3
97+
with:
98+
name: beta-version
99+
path: _build/html
100+
101+
102+
build-tagged:
103+
104+
runs-on: ubuntu-latest
105+
needs: [find-tag, link-check]
90106

91-
- name: Build environment for last tagged version
92-
run: micromamba create -n tutorial-tagged -y -f environment.yaml
107+
steps:
108+
- uses: actions/checkout@v4
109+
with:
110+
ref: ${{ needs.find-tag.outputs.latest-tag }}
111+
fetch-depth: 0
93112

94-
- name: Build last tagged version
95-
run: |
96-
micromamba activate tutorial-tagged
97-
sphinx-build -M html . _build -W --keep-going -a
113+
- uses: prefix-dev/setup-pixi@v0.4.1
114+
continue-on-error: true
115+
id: pixisetup
116+
with:
117+
cache: true
118+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
119+
120+
- name: Build Documentation
121+
if: steps.pixisetup.outcome == 'success'
122+
run: pixi run sphinx-build -M html . _build -W --keep-going -a
123+
98124

99-
- name: Prepare html for upload
100-
run: |
101-
mkdir -p gh-pages/beta
102-
cp -rT _build-beta/html gh-pages/beta
103-
cp -rT _build/html gh-pages
125+
- name: Install mamba
126+
if: steps.pixisetup.outcome == 'failure'
127+
uses: mamba-org/setup-micromamba@v1
128+
with:
129+
environment-file: environment.yaml
130+
131+
- name: build with mamba
132+
if: steps.pixisetup.outcome == 'failure'
133+
shell: bash -leo pipefail {0} {0}
134+
run: sphinx-build -M html . _build -W --keep-going -a
135+
136+
- uses: actions/upload-artifact@v3
137+
with:
138+
name: tagged-version
139+
path: _build/html
104140

141+
prepare-pages:
142+
needs: [build-latest, build-tagged]
143+
runs-on: ubuntu-latest
144+
steps:
145+
- uses: actions/download-artifact@v3
146+
with:
147+
name: tagged-version
148+
path: public
149+
- uses: actions/download-artifact@v3
150+
with:
151+
name: beta-version
152+
path: public/beta
105153
- uses: actions/upload-pages-artifact@v2
106154
with:
107-
path: gh-pages
155+
path: public
156+
108157

109158

110159
deploy:
111-
needs: [build, link-check-last-tagged]
112-
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
160+
needs: prepare-pages
161+
if: github.ref == 'refs/heads/master'
113162
runs-on: ubuntu-latest
114163
permissions:
115164
pages: write
@@ -124,5 +173,4 @@ jobs:
124173
id: deployment
125174
uses: actions/deploy-pages@v2
126175

127-
128-
176+

0 commit comments

Comments
 (0)