|
35 | 35 | required: true |
36 | 36 |
|
37 | 37 | jobs: |
38 | | - build-openedx: |
39 | | - name: Build 'openedx' image |
40 | | - uses: open-craft/phd-cluster-template/.github/workflows/build-service.yml@main |
41 | | - permissions: |
42 | | - packages: write |
43 | | - contents: read |
44 | | - concurrency: |
45 | | - group: build-service:${{ inputs.STRAIN_REPOSITORY }}:${{ inputs.STRAIN_REPOSITORY_BRANCH }}:${{ inputs.INSTANCE_NAME }}:openedx |
46 | | - cancel-in-progress: false |
| 38 | + build: |
| 39 | + name: Build ${{ matrix.service }} service |
| 40 | + uses: open-craft/phd-cluster-template/.github/workflows/build.yml@gabor/experiment |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + service: ["openedx", "mfe"] |
47 | 44 | secrets: |
48 | 45 | SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} |
49 | 46 | with: |
50 | 47 | INSTANCE_NAME: ${{ inputs.INSTANCE_NAME }} |
51 | | - SERVICE: openedx |
52 | | - STRAIN_REPOSITORY: ${{ inputs.STRAIN_REPOSITORY }} |
53 | | - STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} |
54 | | - PICASSO_VERSION: ${{ inputs.PICASSO_VERSION }} |
55 | | - RUNNER_WORKFLOW_LABEL: ${{ inputs.RUNNER_WORKFLOW_LABEL }} |
56 | | - |
57 | | - build-mfe: |
58 | | - name: Build 'mfe' image |
59 | | - uses: open-craft/phd-cluster-template/.github/workflows/build-service.yml@main |
60 | | - permissions: |
61 | | - packages: write |
62 | | - contents: read |
63 | | - concurrency: |
64 | | - group: build-service:${{ inputs.STRAIN_REPOSITORY }}:${{ inputs.STRAIN_REPOSITORY_BRANCH }}:${{ inputs.INSTANCE_NAME }}:mfe |
65 | | - cancel-in-progress: false |
66 | | - secrets: |
67 | | - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} |
68 | | - with: |
69 | | - INSTANCE_NAME: ${{ inputs.INSTANCE_NAME }} |
70 | | - SERVICE: mfe |
| 48 | + SERVICE: ${{ matrix.service }} |
71 | 49 | STRAIN_REPOSITORY: ${{ inputs.STRAIN_REPOSITORY }} |
72 | 50 | STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} |
73 | 51 | PICASSO_VERSION: ${{ inputs.PICASSO_VERSION }} |
| 52 | + PHD_CLI_VERSION: ${{ inputs.PHD_CLI_VERSION }} |
74 | 53 | RUNNER_WORKFLOW_LABEL: ${{ inputs.RUNNER_WORKFLOW_LABEL }} |
| 54 | + UPDATE_ENV_DIR: false |
75 | 55 |
|
76 | | - generate-env-dir: |
| 56 | + update-env-dir: |
| 57 | + name: Update env directory |
| 58 | + uses: open-craft/phd-cluster-template/.github/workflows/generate-env-dir.yml@gabor/experiment |
77 | 59 | needs: |
78 | | - - build-openedx |
79 | | - - build-mfe |
80 | | - name: Generate Environment Directory |
81 | | - uses: open-craft/phd-cluster-template/.github/workflows/generate-env-dir.yml@main |
| 60 | + - build |
82 | 61 | secrets: |
83 | 62 | SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} |
84 | 63 | with: |
85 | 64 | INSTANCE_NAME: ${{ inputs.INSTANCE_NAME }} |
86 | 65 | STRAIN_REPOSITORY: ${{ inputs.STRAIN_REPOSITORY }} |
87 | 66 | STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} |
88 | | - PICASSO_VERSION: ${{ inputs.PICASSO_VERSION }} |
89 | | - PHD_CLI_VERSION: ${{ inputs.PHD_CLI_VERSION }} |
90 | 67 | RUNNER_WORKFLOW_LABEL: ${{ inputs.RUNNER_WORKFLOW_LABEL }} |
91 | | - |
92 | | - commit-and-push: |
93 | | - needs: |
94 | | - - build-openedx |
95 | | - - build-mfe |
96 | | - - generate-env-dir |
97 | | - runs-on: ${{ inputs.RUNNER_WORKFLOW_LABEL }} |
98 | | - concurrency: |
99 | | - group: ${{ inputs.STRAIN_REPOSITORY }}:${{ inputs.STRAIN_REPOSITORY_BRANCH }}:${{ inputs.INSTANCE_NAME }}:batch-build |
100 | | - cancel-in-progress: false |
101 | | - steps: |
102 | | - - name: Setup SSH agent |
103 | | - uses: webfactory/ssh-agent@v0.9.0 |
104 | | - with: |
105 | | - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
106 | | - |
107 | | - - name: Add GitHub to known hosts |
108 | | - run: ssh-keyscan github.com >> ~/.ssh/known_hosts |
109 | | - |
110 | | - - name: Checkout cluster repository |
111 | | - uses: actions/checkout@v4 |
112 | | - with: |
113 | | - repository: ${{ inputs.STRAIN_REPOSITORY }} |
114 | | - ref: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} |
115 | | - fetch-depth: 0 |
116 | | - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} |
117 | | - |
118 | | - - name: Configure git |
119 | | - run: | |
120 | | - git config user.name "GitHub Actions" |
121 | | - git config user.email "actions@github.com" |
122 | | -
|
123 | | - - name: Checkout workflow scripts |
124 | | - uses: actions/checkout@v4 |
125 | | - with: |
126 | | - repository: open-craft/phd-cluster-template |
127 | | - ref: main |
128 | | - path: workflow-scripts |
129 | | - |
130 | | - - name: Setup Python |
131 | | - uses: actions/setup-python@v5 |
132 | | - with: |
133 | | - python-version: 3.12 |
134 | | - cache: 'pip' |
135 | | - |
136 | | - - name: Install PyYAML |
137 | | - run: pip install pyyaml |
138 | | - |
139 | | - - name: Prepare env directory |
140 | | - run: | |
141 | | - set -euo pipefail |
142 | | - rm -rf "instances/${{ inputs.INSTANCE_NAME }}/env" |
143 | | - mkdir -p "instances/${{ inputs.INSTANCE_NAME }}/env" |
144 | | -
|
145 | | - - name: Download env artifact |
146 | | - uses: actions/download-artifact@v4 |
147 | | - with: |
148 | | - name: tutor-env-${{ inputs.INSTANCE_NAME }} |
149 | | - path: instances/${{ inputs.INSTANCE_NAME }}/env |
150 | | - |
151 | | - - name: Update config.yml with all service image tags |
152 | | - env: |
153 | | - CONFIG_FILE: instances/${{ inputs.INSTANCE_NAME }}/config.yml |
154 | | - SCRIPT_PATH: workflow-scripts/.github/workflows/scripts/update_config_image.py |
155 | | - OPENEDX_IMAGE_NAME: ${{ needs.build-openedx.outputs.image_name }} |
156 | | - OPENEDX_IMAGE_TAG: ${{ needs.build-openedx.outputs.image_tag }} |
157 | | - MFE_IMAGE_NAME: ${{ needs.build-mfe.outputs.image_name }} |
158 | | - MFE_IMAGE_TAG: ${{ needs.build-mfe.outputs.image_tag }} |
159 | | - run: | |
160 | | - # Update config.yml for openedx service |
161 | | - python "$SCRIPT_PATH" \ |
162 | | - --config-file "$CONFIG_FILE" \ |
163 | | - --service "openedx" \ |
164 | | - --image-name "$OPENEDX_IMAGE_NAME" \ |
165 | | - --image-tag "$OPENEDX_IMAGE_TAG" |
166 | | -
|
167 | | - # Update config.yml for mfe service |
168 | | - python "$SCRIPT_PATH" \ |
169 | | - --config-file "$CONFIG_FILE" \ |
170 | | - --service "mfe" \ |
171 | | - --image-name "$MFE_IMAGE_NAME" \ |
172 | | - --image-tag "$MFE_IMAGE_TAG" |
173 | | -
|
174 | | - - name: Commit and push changes |
175 | | - env: |
176 | | - INSTANCE_NAME: ${{ inputs.INSTANCE_NAME }} |
177 | | - BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} |
178 | | - SCRIPT_PATH: workflow-scripts/.github/workflows/scripts/update_config_image.py |
179 | | - CONFIG_FILE: instances/${{ inputs.INSTANCE_NAME }}/config.yml |
180 | | - OPENEDX_IMAGE_NAME: ${{ needs.build-openedx.outputs.image_name }} |
181 | | - OPENEDX_IMAGE_TAG: ${{ needs.build-openedx.outputs.image_tag }} |
182 | | - MFE_IMAGE_NAME: ${{ needs.build-mfe.outputs.image_name }} |
183 | | - MFE_IMAGE_TAG: ${{ needs.build-mfe.outputs.image_tag }} |
184 | | - run: | |
185 | | - set -euo pipefail |
186 | | -
|
187 | | - git add -A instances/$INSTANCE_NAME |
188 | | -
|
189 | | - if git diff --cached --quiet; then |
190 | | - echo "No changes to commit" |
191 | | - exit 0 |
192 | | - fi |
193 | | -
|
194 | | - git commit -m "chore: update openedx, mfe images and tutor config for $INSTANCE_NAME" |
195 | | -
|
196 | | - for i in 1 2 3; do |
197 | | - if git push; then |
198 | | - exit 0 |
199 | | - fi |
200 | | - sleep $((i*i)) |
201 | | - git pull origin "$BRANCH" --rebase |
202 | | - # Re-apply all config updates on top of latest base in case of rebase changes |
203 | | - python "$SCRIPT_PATH" \ |
204 | | - --config-file "$CONFIG_FILE" \ |
205 | | - --service "openedx" \ |
206 | | - --image-name "$OPENEDX_IMAGE_NAME" \ |
207 | | - --image-tag "$OPENEDX_IMAGE_TAG" |
208 | | - python "$SCRIPT_PATH" \ |
209 | | - --config-file "$CONFIG_FILE" \ |
210 | | - --service "mfe" \ |
211 | | - --image-name "$MFE_IMAGE_NAME" \ |
212 | | - --image-tag "$MFE_IMAGE_TAG" |
213 | | - git add instances/$INSTANCE_NAME/config.yml |
214 | | - git add instances/$INSTANCE_NAME/env |
215 | | - if git diff --cached --quiet; then |
216 | | - echo "No additional changes after rebase" |
217 | | - else |
218 | | - git commit -m "chore: update openedx, mfe images and tutor config for $INSTANCE_NAME (retry $i)" || true |
219 | | - fi |
220 | | - done |
221 | | - exit 1 |
0 commit comments