New version (#431) #145
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: ECR | |
on: | |
release: | |
types: | |
- published | |
push: | |
paths-ignore: | |
- 'deploy/**' | |
- 'docs/**' | |
branches: | |
- main | |
jobs: | |
publisher: | |
if: ${{ github.event.pusher.name != 'sti-bot' }} | |
name: Publish | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
ECR_REGISTRY: 407967248065.dkr.ecr.us-east-2.amazonaws.com/index-provider | |
PUBLIC_ECR_REGISTRY: public.ecr.aws/storetheindex | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Determine Container Tag | |
run: | | |
IMAGE_TAG="${GITHUB_REF#refs/tags/v}" | |
if test "${IMAGE_TAG}" = "${GITHUB_REF}"; then | |
IMAGE_TAG="$(date '+%Y%m%d%H%M%S')-${GITHUB_SHA}" | |
fi | |
echo "Using image tag: ${IMAGE_TAG}" | |
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV | |
- name: AWS Login | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: "arn:aws:iam::407967248065:role/common/github_actions" | |
role-duration-seconds: 1200 | |
- name: Login to Amazon ECR | |
run: | | |
aws ecr get-login-password | docker login --username AWS --password-stdin ${ECR_REGISTRY} | |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${PUBLIC_ECR_REGISTRY} | |
- name: Publish Container Image | |
env: | |
DOCKER_BUILDKIT: '1' | |
run: | | |
IMAGE_NAME="${ECR_REGISTRY}/index-provider:${IMAGE_TAG}" | |
PUBLIC_IMAGE_NAME="${PUBLIC_ECR_REGISTRY}/index-provider:${IMAGE_TAG}" | |
docker build -t "${IMAGE_NAME}" -t "${PUBLIC_IMAGE_NAME}" . | |
docker push "${IMAGE_NAME}" | |
echo "Published image ${IMAGE_NAME}" | |
docker push "${PUBLIC_IMAGE_NAME}" | |
echo "Published image ${PUBLIC_IMAGE_NAME}" |