Skip to content

initial-image-build-workflow #59

initial-image-build-workflow

initial-image-build-workflow #59

Workflow file for this run

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:
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: |
echo "YEAR=$(date '+%Y')" >> $GITHUB_ENV
echo "USER_NAME=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f4)" >> $GITHUB_ENV
echo "REPO_NAME=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f5)" >> $GITHUB_ENV
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:
status: ${{ steps.create_student_submodule.outcome }}
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