-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Check and Create ECR Repository | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
service_name: | ||
description: 'The name of the Service' | ||
required: true | ||
service_Type: | ||
description: 'Type of service' | ||
required: true | ||
environment: | ||
description: 'Environment classification for servers' | ||
required: true | ||
|
||
env: | ||
ECR_REPOSITORY_NAME: ${{ inputs.service_name }}-${{ inputs.service_type }}-${{ inputs.environment }} | ||
|
||
jobs: | ||
check_and_create_ecr: | ||
runs-on: ubuntu-latest | ||
|
||
- name: Check if ECR repository exists | ||
id: ecr_exists | ||
shell: bash | ||
run: | | ||
set +e | ||
aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY_NAME }} | ||
exit_code=$? | ||
set -e | ||
echo "ecr_exists=$($exit_code != 0 ? 'false' : 'true')" >> $GITHUB_OUTPUT | ||
- name: Create ECR repository if not exists | ||
if: steps.ecr_exists.outputs.ecr_exists == 'false' | ||
shell: bash | ||
run: | | ||
aws ecr create-repository --repository-name ${{ env.ECR_REPOSITORY_NAME }} | ||
- name: Repository Dispatch | ||
if: steps.ecr_exists.outputs.ecr_exists == 'false' | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ inputs.github_token }} | ||
repository: team-xquare/xquare-gitops-repo | ||
event-type: add_ecr | ||
client-payload: | | ||
{ | ||
"repository_name" : "${{ env.ECR_REPOSITORY_NAME }}", | ||
"service_name" : "${{ inputs.service_name }}", | ||
"service_type" : "${{ inputs.service_type }}", | ||
"environment" : "${{ inputs.environment }}" | ||
} | ||
- name: Return repository name | ||
id: ecr_name | ||
shell: bash | ||
run: echo "repository_name=${{ env.ECR_REPOSITORY_NAME }}" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.