Skip to content

Commit e0260bd

Browse files
authored
add sync readme to ecr public (#345)
1 parent e7fab60 commit e0260bd

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ jobs:
176176

177177
- name: Sync Readme to Dockerhub
178178
run: make sync-readme-to-dockerhub
179+
180+
- name: Sync Readme to ECR Public
181+
run: make sync-readme-to-ecr-public
179182

180183
- name: Create NTH README Update PR
181184
run: make create-release-prep-pr-readme

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ generate-k8s-yaml:
120120
sync-readme-to-dockerhub:
121121
${MAKEFILE_PATH}/scripts/sync-readme-to-dockerhub
122122

123+
sync-readme-to-ecr-public:
124+
@ECR_REGISTRY=${ECR_REGISTRY} ${MAKEFILE_PATH}/scripts/ecr-public-login
125+
${MAKEFILE_PATH}/scripts/sync-readme-to-ecr-public
126+
123127
ekscharts-sync:
124128
${MAKEFILE_PATH}/scripts/sync-to-aws-eks-charts -b ${BINARY_NAME} -r ${REPO_FULL_NAME}
125129

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<a href="https://goreportcard.com/report/github.com/aws/aws-node-termination-handler">
1616
<img src="https://goreportcard.com/badge/github.com/aws/aws-node-termination-handler" alt="go-report-card">
1717
</a>
18-
<a href="https://travis-ci.org/aws/aws-node-termination-handler">
19-
<img src="https://travis-ci.org/aws/aws-node-termination-handler.svg?branch=main" alt="build-status">
20-
</a>
2118
<a href="https://codecov.io/gh/aws/aws-node-termination-handler">
2219
<img src="https://img.shields.io/codecov/c/github/aws/aws-node-termination-handler" alt="build-status">
2320
</a>
@@ -26,6 +23,8 @@
2623
</a>
2724
</p>
2825

26+
![NTH Continuous Integration and Release](https://github.com/aws/aws-node-termination-handler/workflows/NTH%20Continuous%20Integration%20and%20Release/badge.svg)
27+
2928
<div>
3029
<hr>
3130
</div>

scripts/sync-readme-to-ecr-public

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5+
REPO_NAME="aws-node-termination-handler"
6+
#about and usage section char max
7+
MAX_CHAR_COUNT=10240
8+
USAGE_TEXT="See About section"
9+
ADDITIONAL_MSG="...
10+
11+
**truncated due to char limits**...
12+
A complete version of the ReadMe can be found [here](https://github.com/aws/aws-node-termination-handler#aws-node-termination-handler)\""
13+
14+
15+
if git --no-pager diff --name-only HEAD^ HEAD | grep 'README.md'; then
16+
#converting to json to insert esc chars, then replace newlines for proper markdown render
17+
raw_about=$(jq -n --arg msg "$(<$SCRIPTPATH/../README.md)" '{"usageText": $msg}' | jq '.usageText' | sed 's/\\n/\
18+
/g')
19+
char_to_trunc="$(($MAX_CHAR_COUNT-${#ADDITIONAL_MSG}))"
20+
raw_truncated="${raw_about:0:$char_to_trunc}"
21+
raw_truncated+="$ADDITIONAL_MSG"
22+
resp=$(aws ecr-public put-repository-catalog-data --repository-name="${REPO_NAME}" --catalog-data aboutText="${raw_truncated}",usageText="${USAGE_TEXT}" --region us-east-1)
23+
24+
if [[ $resp -ge 1 ]]; then
25+
echo "README sync to ecr-public failed"
26+
exit 1
27+
else
28+
echo "README sync to ecr-public succeeded!"
29+
fi
30+
else
31+
echo "README.md did not change in the last commit. Not taking any action."
32+
fi

0 commit comments

Comments
 (0)