-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 3.09 KB
/
create-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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: |
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}/
env:
year: ${year}
user_name: ${user_name}
repo_name: ${repo_name}
outputs:
status: ${{ steps.create_student_submodule.outcome }}
year: ${{ steps.create_student_submodule.env.year }}
user_name: ${{ steps.create_student_submodule.env.user_name }}
repo_name: ${{ steps.create_student_submodule.env.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