Skip to content

Commit 25ebe3d

Browse files
feat: finalize initial implementation (#10)
SE-6524 Signed-off-by: Gabor Boros <gabor@opencraft.com> Co-authored-by: Kaustav Banerjee <reachout@kaustav.in>
1 parent 2f26490 commit 25ebe3d

34 files changed

+768
-597
lines changed

.github/workflows/build-all.yml

Lines changed: 13 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -35,187 +35,33 @@ on:
3535
required: true
3636

3737
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"]
4744
secrets:
4845
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
4946
with:
5047
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 }}
7149
STRAIN_REPOSITORY: ${{ inputs.STRAIN_REPOSITORY }}
7250
STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }}
7351
PICASSO_VERSION: ${{ inputs.PICASSO_VERSION }}
52+
PHD_CLI_VERSION: ${{ inputs.PHD_CLI_VERSION }}
7453
RUNNER_WORKFLOW_LABEL: ${{ inputs.RUNNER_WORKFLOW_LABEL }}
54+
UPDATE_ENV_DIR: false
7555

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
7759
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
8261
secrets:
8362
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
8463
with:
8564
INSTANCE_NAME: ${{ inputs.INSTANCE_NAME }}
8665
STRAIN_REPOSITORY: ${{ inputs.STRAIN_REPOSITORY }}
8766
STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }}
88-
PICASSO_VERSION: ${{ inputs.PICASSO_VERSION }}
89-
PHD_CLI_VERSION: ${{ inputs.PHD_CLI_VERSION }}
9067
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

.github/workflows/build-service.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)