Skip to content

Commit 4b3aec7

Browse files
committed
update workflows
1 parent b5db600 commit 4b3aec7

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Build Evaluation Function Image
33
on:
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
106
build-file:
117
type: string
128
description: "The path to the Dockerfile to build"
@@ -39,7 +35,6 @@ jobs:
3935
build:
4036
name: Build and Push Docker Image
4137
runs-on: ubuntu-latest
42-
if: github.repository != inputs.template-repository-name
4338
concurrency:
4439
group: ${{ github.ref }}
4540
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref_name != github.event.repository.default_branch }}

.github/workflows/deploy.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ name: Build and Deploy Evaluation Function to Lambda Feedback
33
on:
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"
@@ -48,7 +48,6 @@ jobs:
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
@@ -74,9 +75,16 @@ jobs:
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

Comments
 (0)