This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Update identity-widget_v1.js (#79) #25
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
name: CI to ECR | |
on: | |
push: | |
branches: | |
- 'aws' | |
jobs: | |
build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clean Workspace | |
uses: AutoModality/action-clean@v1 | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: "835790907524.dkr.ecr.eu-west-1.amazonaws.com" # ??? # ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
for file in $(find . -name "Dockerfile*"); do | |
image_name=blog-content | |
tag_name=${GITHUB_REF##*/}-${GITHUB_SHA::7} | |
echo "Building image $image_name:$tag_name" | |
docker build -t $ECR_REGISTRY/$image_name:$tag_name -f $file . | |
echo "Pushing image $image_name:$tag_name" | |
docker push $ECR_REGISTRY/$image_name:$tag_name | |
done | |
- name: Clone related k8s repo | |
uses: actions/checkout@v3 | |
with: | |
repository: almacareer/blog-content--k8s | |
ref: aws | |
path: blog-content--k8s | |
ssh-key: ${{ secrets.SSH_KEY }} | |
- name: Update image in Helm Chart | |
run: | | |
export IMAGE_VERSION="${GITHUB_REF##*/}-${GITHUB_SHA::7}" | |
echo "Latest version is: $IMAGE_VERSION" | |
export VERSION_CHART=$(grep -oP 'appVersion: .*' blog-content--k8s/engineering-blog/Chart.yaml | awk '{ print $2 }') | |
if [ "${IMAGE_VERSION}" == "${VERSION_CHART}" ]; then | |
echo "Nothing to change." | |
exit 0 | |
fi | |
sed -i -r -e "s/appVersion: .*/appVersion: $IMAGE_VERSION/" blog-content--k8s/engineering-blog/Chart.yaml | |
cd blog-content--k8s/ | |
git add --all | |
git config user.name "GitHub Action" | |
git config user.email github-actions@github.com | |
git commit -am "version: $IMAGE_VERSION" | |
git push origin HEAD:aws |