@@ -3,15 +3,15 @@ name: Build and Deploy Evaluation Function to Lambda Feedback
33on :
44 workflow_call :
55 inputs :
6+ template-repository-name :
7+ type : string
8+ description : " The name of the repository where the template is located"
9+ required : true
610 region :
711 type : string
812 description : " The AWS region to deploy to"
913 default : " eu-west-2"
1014 required : false
11- template-repository-name :
12- type : string
13- description : " The name of the repository where the template is located"
14- required : true
1515 build-file :
1616 type : string
1717 description : " The path to the Dockerfile to build"
4848 setup :
4949 name : Setup
5050 runs-on : ubuntu-latest
51- if : github.repository != inputs.template-repository-name
5251 outputs :
5352 evaluation_function_name : ${{ steps.evaluation_function_name.outputs.name }}
5453 permissions :
@@ -62,10 +61,12 @@ jobs:
6261 fetch-depth : 0
6362
6463 - name : Check for config.json
64+ if : github.repository != inputs.template-repository-name
6565 run : |
6666 if [[ ! -f "config.json" ]]; then echo "Error: config.json not found."; exit 1; fi
6767
6868 - name : Parse config.json
69+ if : github.repository != inputs.template-repository-name
6970 id : config
7071 run : |
7172 echo 'config<<EOF' >> $GITHUB_OUTPUT
7475
7576 - name : Get Evaluation Function Name
7677 id : evaluation_function_name
78+ env :
79+ TEMPLATE_REPOSITORY : ${{ github.repository == inputs.template-repository-name }}
7780 run : |
78- functionName="${{fromJson(steps.config.outputs.config).EvaluationFunctionName}}"
79- if [[ -z "$functionName" ]]; then echo "Set EvaluationFunctionName in config.json"; exit 1; fi
81+ if [[ $TEMPLATE_REPOSITORY == true ]]; then
82+ # Convert repository name to function name
83+ functionName=$(echo "${{ github.event.repository.name }}" | gsed -E 's/([A-Z])([A-Z]*)/\L\1\2/g' | gsed -E 's/-([a-z])/\U\1/g' | tr -d '-')
84+ else
85+ functionName="${{fromJson(steps.config.outputs.config).EvaluationFunctionName}}"
86+ if [[ -z "$functionName" ]]; then echo "Set EvaluationFunctionName in config.json"; exit 1; fi
87+ fi
8088 echo "name=$functionName" >> "$GITHUB_OUTPUT"
8189
8290 build :
@@ -115,6 +123,7 @@ jobs:
115123
116124 deploy-production :
117125 uses : ./.github/workflows/lambda_deploy.yml
126+ if : github.repository != inputs.template-repository-name
118127 needs : [setup, build]
119128 with :
120129 environment : production
0 commit comments