initial-image-build-workflow #48
Workflow file for this run
This file contains 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: "initial-image-build-workflow" | ||
on: | ||
# Trigger a specific workflow run on demand without need for a code push/pull request | ||
workflow_dispatch: | ||
inputs: | ||
githubRepo: | ||
description: "Link of public github repo to deploy" | ||
required: true | ||
jobs: | ||
create_submodule: | ||
outputs: | ||
status: ${{ steps.create_student_submodule.outcome }} | ||
permissions: | ||
contents: "write" | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- id: create_student_submodule | ||
name: Add student's repo as a submodule | ||
run: | | ||
year=$(date '+%Y') | ||
user_name=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f4) | ||
repo_name=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f5) | ||
if [ ! -d submissions-${year}/${user_name}-${repo_name} ]; then | ||
echo "Adding ${{ github.event.inputs.githubRepo }} to ./submissions-${year}/${user_name}-${repo_name}/${user_name}-${repo_name} as a submodule" | ||
git config --global user.name github-actions | ||
git config --global user.email [email protected] | ||
git submodule add ${{ github.event.inputs.githubRepo }} ./submissions-${year}/${user_name}-${repo_name}/${user_name}-${repo_name} | ||
git commit -m "Added ${user_name}-${repo_name} as a submodule by github-actions" | ||
git push | ||
else | ||
echo "Submodule already exists, terminating github actions" | ||
fi | ||
cd ./submissions-${year}/${user_name}-${repo_name}/ | ||
outputs: | ||
year: ${year} | ||
user_name: ${user_name} | ||
repo_name: ${repo_name} | ||
create_docker_image: | ||
needs: create_submodule | ||
permissions: | ||
contents: "write" | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
if: needs.create_submodule.outputs.status == 'success' | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Github dependents info | ||
run: pip install -U github-dependents-info | ||
- name: Get submodule's dependencies in JSON file | ||
run: github-dependents-info --repo ${needs.create_submodule.outputs..user_name}/${needs.create_submodule.outputs..repo_name} --json | ||
- name: Check if the JSON file was created successfully | ||
run: | | ||
if [[ -f ${needs.create_submodule.outputs..user_name}/${needs.create_submodule.outputs..repo_name}.json ]]; then | ||
echo "${needs.create_submodule.outputs..user_name}/${needs.create_submodule.outputs..repo_name}.json exists!" | ||
else | ||
echo "${needs.create_submodule.outputs..user_name}/${needs.create_submodule.outputs..repo_name}.json does not exist!" | ||
fi | ||
# need to add export DOCKER_BUILDKIT=1 before building python docker image |