forked from Netflix/consoleme
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (51 loc) · 2.16 KB
/
docker-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
46
47
48
49
50
51
52
53
54
55
name: Create and publish docker image on ECR
on:
push:
branches: master
tags:
- "*"
jobs:
ecr_public:
runs-on: ubuntu-latest
name: ECR public action
if: github.repository == 'Netflix/consoleme'
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install AWS CLI
run: |-
pip install awscli
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Public ECR
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CONSOLEME_DEMO_USER_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CONSOLEME_DEMO_USER_SECRET_ACCESS_KEY }}
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
- name: Build ConsoleMe
run: |
docker build -t consoleme .
- name: Tag, and push unstable image to Amazon ECR
run: |
docker tag consoleme public.ecr.aws/consoleme/consoleme:unstable
docker push --all-tags public.ecr.aws/consoleme/consoleme
- name: Tag, and push versioned image to ECR on tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
# Extract tags from version
export CONSOLEME_VERSION=$(python3 setup.py -q --version | sed -r 's/\+/\./g')
export CONSOLEME_MAJOR=$(cut -d '.' -f 1 <<< "$CONSOLEME_VERSION")
export CONSOLEME_MINOR=$(cut -d '.' -f 1,2 <<< "$CONSOLEME_VERSION")
export CONSOLEME_PATCH=$(cut -d '.' -f 1,2,3 <<< "$CONSOLEME_VERSION")
# Tag image
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_VERSION
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_MAJOR
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_MINOR
docker tag consoleme public.ecr.aws/consoleme/consoleme:$CONSOLEME_PATCH
docker tag consoleme public.ecr.aws/consoleme/consoleme:latest
docker push --all-tags public.ecr.aws/consoleme/consoleme