-
Notifications
You must be signed in to change notification settings - Fork 25
128 lines (121 loc) · 4.02 KB
/
build_one.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: build one
on:
workflow_call:
inputs:
project:
description: Project to test
required: true
type: string
type:
description: hack
required: true
type: string
branch:
description: Branch suffix to push the evaluated projects to
type: string
default: ''
workflow_dispatch:
inputs:
project:
description: Project to build (dryrun only)
required: true
type: string
jobs:
infer_runner:
name: infer runner
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
timeout-minutes: 10
outputs:
runner: ${{ steps.set-runner.outputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: install deps
# Minimal required deps to run the following script
run: pip install doit pyyaml
- name: infer runner
id: set-runner
run: |
RUNNER=$(doit util_gh_runner:${{ inputs.project }} | tail -n -1)
echo "GH runner: $RUNNER"
echo "RUNNER=$RUNNER" >> $GITHUB_OUTPUT
build_one:
needs: infer_runner
name: build ${{ inputs.project }}
runs-on: ${{ needs.infer_runner.outputs.runner }}
defaults:
run:
shell: bash -l {0}
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
auto-activate-base: false
activate-environment: examples-gallery-manage
environment-file: envs/environment-${{ needs.infer_runner.outputs.runner }}.lock
- name: list files
run: doit build_list_existing_files:${{ inputs.project }}
- name: prepare project
run: doit build_prepare_project:${{ inputs.project }}
- name: process notebooks
run: doit build_process_notebooks:${{ inputs.project }}
- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.project }}
path: doc/gallery/${{ inputs.project }}/
retention-days: 3
- name: clean project folder
run: doit clean build_list_existing_files:${{ inputs.project }}
- name: deploy project
# Only push to the branch when the workflow is called by pr_flow.yml -> build.yml
# Could be updated to allow to build projects using worfklow_dispatch to see
# the evaluated output of a project.
if: inputs.type == 'workflow_call'
run: |
# Create local branch to switch back to it later, before cleaning up and diffing
git checkout -b local_branch_qpeori
DIR=${{ inputs.project }}
BRANCHNAME="tmp_evaluated_fghgf_${{ inputs.branch }}"
REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git"
git config user.email "[email protected]"
git config user.name "github-actions"
# Move doc to move to a tmp directory
mv ./doc/gallery/$DIR ./tmp
# Checkout tmp dev branch
if git ls-remote --exit-code --heads "$REPO_URL" "$BRANCHNAME"
then
echo "Remote branch already there, fetching $BRANCHNAME"
git fetch $REPO_URL $BRANCHNAME:refs/remotes/$BRANCHNAME
git checkout $BRANCHNAME
git log --oneline
else
echo "Remote branch not found"
git switch --orphan $BRANCHNAME
fi
mkdir -p doc/gallery
git diff --name-only
if [ -d ./doc/gallery/$DIR ]; then rm -rf ./doc/gallery/$DIR; fi
mkdir ./doc/gallery/$DIR
mv ./tmp/* ./doc/gallery/$DIR
rmdir ./tmp
git add ./doc/gallery/$DIR
git commit -m "adding $DIR"
echo "git status"
git status
echo "git push"
git push -u origin HEAD:$BRANCHNAME
git checkout local_branch_qpeori
- name: clean up
run: doit clean --clean-dep build:${{ inputs.project }}
- name: git diff
run: git diff --name-only
- name: check clean up
run: git diff --quiet --exit-code