forked from mreferre/eksutils
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (74 loc) · 2.84 KB
/
master.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: prod
on:
pull_request:
types: [closed]
branches:
- master
workflow_dispatch:
env:
STACK_NAME: ${{ github.event.repository.name }}
AWS_DEFAULT_REGION: eu-west-1
jobs:
BuildDocker:
name: build-docker-hub
#if: "github.event.pull_request.merged || github.ref == 'refs/heads/master'"
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build, tag, and push image to Amazon ECR Public
id: build-image-ecr-public
env:
ECR_REGISTRY: 'allamand'
ECR_REPOSITORY: ${{ github.event.repository.name }}
IMAGE_TAG: ${{ github.sha }}
#IMAGE_TAG: ${{ github.event.number }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
echo $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
#update latest
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
BuildECR:
name: build-ecr-public
#if: "github.event.pull_request.merged || github.ref == 'refs/heads/master'"
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Public ECR
uses: docker/login-action@v1
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
- name: Build, tag, and push image to Amazon ECR Public
id: build-image-ecr-public
env:
ECR_REGISTRY: 'public.ecr.aws/seb-demo'
ECR_REPOSITORY: ${{ github.event.repository.name }}
IMAGE_TAG: ${{ github.sha }}
#IMAGE_TAG: ${{ github.event.number }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
echo $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
#update latest
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"