Build 'openedx' image for 'teak-demo' on 'main' branch #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Service Image | ||
run-name: Build '${{ inputs.SERVICE }}' image for '${{ inputs.INSTANCE_NAME }}' on '${{ inputs.STRAIN_REPOSITORY_BRANCH }}' branch | ||
env: | ||
PICASSO_VERSION: main | ||
PYTHON_VERSION: "3.12" | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
INSTANCE_NAME: | ||
description: "Instance to build" | ||
type: string | ||
SERVICE: | ||
description: "Service to build" | ||
default: "openedx" | ||
type: choice | ||
options: | ||
- openedx | ||
- mfe | ||
STRAIN_REPOSITORY_BRANCH: | ||
description: "Branch to clone the strain from" | ||
default: "main" | ||
type: string | ||
BUILDKIT_MAX_PARALLELISM: | ||
description: "Number of layers to build at the same time." | ||
default: "3" | ||
type: string | ||
jobs: | ||
build: | ||
permissions: | ||
contents: write | ||
name: Build with Picasso | ||
uses: eduNEXT/picasso/.github/workflows/build.yml@main | ||
with: | ||
BUILDKIT_MAX_PARALLELISM: ${{ fromJSON(inputs.BUILDKIT_MAX_PARALLELISM) }} | ||
STRAIN_REPOSITORY: ${{ github.repository }} | ||
STRAIN_REPOSITORY_BRANCH: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} | ||
STRAIN_PATH: "instances/${{ inputs.INSTANCE_NAME }}" | ||
SERVICE: ${{ inputs.SERVICE }} | ||
USE_DYNAMIC_IMAGE_TAG: true | ||
UPDATE_IMAGE_TAG_IN_REPO: true | ||
ADD_RANDOM_SUFFIX_TO_IMAGE_TAG: true | ||
RANDOM_SUFFIX_LENGTH: "8" | ||
TIMESTAMP_FORMAT: "%Y%m%d" | ||
PICASSO_VERSION: ${{ env.PICASSO_VERSION }} | ||
Check failure on line 47 in .github/workflows/build.yml
|
||
PYTHON_VERSION: ${{ env.PYTHON_VERSION }} | ||
secrets: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: ${{ secrets.AWS_REGION }} | ||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | ||
upload-tutor-env: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
name: Upload Tutor Environment | ||
needs: build | ||
steps: | ||
- name: Checkout Picasso repository for utility scripts | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: edunext/picasso | ||
ref: ${{ env.PICASSO_VERSION }} | ||
path: picasso | ||
- name: Checkout strains repository for build configurations | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.STRAIN_REPOSITORY }} | ||
ref: ${{ inputs.STRAIN_REPOSITORY_BRANCH }} | ||
ssh-key: ${{ inputs.STRAIN_REPOSITORY != github.repository && secrets.SSH_PRIVATE_KEY || '' }} | ||
path: strains | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install necessary requirements for workflow scripts | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
pip install -r picasso/requirements/base.txt | ||
- name: Get Tutor Configurations from config.yml and set them as an environment variable | ||
working-directory: ${{ github.workspace }} | ||
env: | ||
REQUIRED_KEYS: TUTOR_VERSION | ||
OPTIONAL_KEYS: DOCKER_REGISTRY | ||
CONFIG_FILE: strains/instances/${{ inputs.INSTANCE_NAME }}/config.yml | ||
SCRIPT_PATH: picasso/.github/workflows/scripts/get_tutor_config.py | ||
run: | | ||
ENV_VARS=$(python $SCRIPT_PATH --config-file $CONFIG_FILE --required-keys $REQUIRED_KEYS --optional-keys $OPTIONAL_KEYS) | ||
echo "$ENV_VARS" >> $GITHUB_ENV | ||
- name: Install Tutor and its dependencies from the version specified in the config.yml | ||
run: | | ||
pip install git+https://github.com/overhangio/tutor.git@$TUTOR_VERSION | ||
tutor config save | ||
- name: Update Tutor configuration in remote repository | ||
working-directory: ${{ github.workspace }}/strains | ||
env: | ||
STRAIN_PATH: strains/instances/${{ inputs.INSTANCE_NAME }} | ||
CONFIG_FILE: instances/${{ inputs.INSTANCE_NAME }}/config.yml | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
git restore $CONFIG_FILE | ||
git add $STRAIN_PATH | ||
if git diff --cached --quiet; then | ||
echo "No changes to commit" | ||
else | ||
git commit -m "chore: update tutor config for ${{ inputs.INSTANCE_NAME }} image" | ||
git push | ||
fi |