Skip to content

initial-image-build-workflow #358

initial-image-build-workflow

initial-image-build-workflow #358

Workflow file for this run

name: "initial-image-build-workflow"
on:
workflow_dispatch:
inputs:
githubRepo:
description: "Link of public github repo to deploy"
required: true
outputs:
student_url:
description: "Link of student's repository"
value: ${{ jobs.get_students_url.outputs.student_url }}

Check failure on line 12 in .github/workflows/create-image.yml

View workflow run for this annotation

GitHub Actions / initial-image-build-workflow

Invalid workflow file

The workflow is not valid. .github/workflows/create-image.yml (Line: 12, Col: 16): Unrecognized named-value: 'jobs'. Located at position 1 within expression: jobs.get_students_url.outputs.student_url
jobs:
create_student_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')
initial_user_name=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f4)
initial_repo_name=$(echo "${{ github.event.inputs.githubRepo }}" | cut -d'/' -f5)
user_name_lower_case=$(echo "$initial_user_name" | tr '[:upper:]' '[:lower:]')
repo_name_lower_case=$(echo "$initial_repo_name" | tr '[:upper:]' '[:lower:]')
user_name=$(echo "$user_name_lower_case" | tr '._' '-')
repo_name=$(echo "$repo_name_lower_case" | tr '._' '-')
echo "year=$(date '+%Y')" >> "$GITHUB_OUTPUT"
echo "user_name=$user_name" >> "$GITHUB_OUTPUT"
echo "repo_name=$repo_name" >> "$GITHUB_OUTPUT"
if [ ! -d submissions-${year} ]; then
mkdir submissions-${year}
fi
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]
cd ./submissions-${year}
mkdir ${user_name}-${repo_name}
cd ./${user_name}-${repo_name}
git submodule add ${{ github.event.inputs.githubRepo }} ./${user_name}-${repo_name}
git commit -m "Added ${user_name}-${repo_name} as a submodule by github-actions"
git push
echo "STATUS=$(echo 'success')" >> "$GITHUB_OUTPUT"
else
echo "Submodule already exists, terminating github actions"
echo "STATUS=$(echo 'failure')" >> "$GITHUB_OUTPUT"
fi
outputs:
status: ${{ steps.create_student_submodule.outputs.STATUS }}
year: ${{ steps.create_student_submodule.outputs.year}}
user_name: ${{ steps.create_student_submodule.outputs.user_name }}
repo_name: ${{ steps.create_student_submodule.outputs.repo_name }}
dockerise-image:
uses: ./.github/workflows/dockerise-image.yml
needs: create_student_submodule
with:
user_name: ${{ needs.create_student_submodule.outputs.user_name }}
repo_name: ${{ needs.create_student_submodule.outputs.repo_name }}
year: ${{ needs.create_student_submodule.outputs.year }}
submodule_status: ${{ needs.create_student_submodule.outputs.status }}
repo_url: ${{ github.event.inputs.githubRepo }}
secrets:
DEPENDENCY_GRAPH_TOKEN: ${{ secrets.DEPENDENCY_GRAPH_TOKEN }}
trigger_deployment:
uses: ./.github/workflows/deploy-image.yml
needs: dockerise-image
with:
user_name: ${{ needs.dockerise-image.outputs.user_name }}
repo_name: ${{ needs.dockerise-image.outputs.repo_name }}
year: ${{ needs.dockerise-image.outputs.year }}
image: ${{ needs.dockerise-image.outputs.image_name }}
get_students_url:
runs-on: ubuntu-latest
needs: trigger_deployment
steps:
- name: echo_success
run: echo "Successfully retrieved repo_url ${{ needs.trigger_deployment.outputs.student_url }}"
outputs:
student_url: ${{ needs.trigger_deployment.outputs.student_url }}