-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.34 KB
/
publish-ecr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: ECR
on:
release:
types:
- published
push:
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/ipni
steps:
- name: Checkout
uses: actions/checkout@v2
- 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@v1
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}
- name: Publish Container Image
run: |
IMAGE_NAME="${ECR_REGISTRY}/dhstore:${IMAGE_TAG}"
docker build -t "${IMAGE_NAME}" .
docker push "${IMAGE_NAME}"
echo "Published image ${IMAGE_NAME}"