forked from github-developer/example-actions-flux-eks
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.49 KB
/
build.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
# build.yml
on:
pull_request:
paths:
- app/**
push:
paths:
- app/**
branches: # array of glob patterns matching against refs/heads. Optional; defaults to all
- master # triggers on pushes that contain changes in master
name: Build and Push to ECR
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
env:
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_OUTPUT: json
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CONTAINER_IMAGE: nii-poc-example-eks:${{ github.sha }}
jobs:
build-and-push:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
# Add steps here like linting, testing, minification, etc.
- name: Setup ECR
run: |
# Login to AWS ECR
$( aws ecr get-login --no-include-email )
- name: Build and tag the image
run: |
# Build and tag the image
docker build \
-t $CONTAINER_IMAGE \
-t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE ./app
# Add additional steps here like scanning of image
# Only push to registry on master
- name: Push
if: github.ref == 'refs/heads/master'
run: |
# Push image to AWS ECR
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE