-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (62 loc) · 2.9 KB
/
ci.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
name: Build
on:
push:
paths-ignore:
- '**.md'
jobs:
ci:
name: Build and Deploy
runs-on: ubuntu-18.04
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v1
with:
path: /tmp/docker-cache
key: docker-1-cache-${{ hashFiles('backend/stack.yaml.lock') }}-${{ hashFiles('backend/office-tracker.cabal') }}-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
docker-1-cache-
- name: Cache buildkit cache
uses: actions/cache@v1
with:
path: /tmp/buildkit-cache
key: buildkit-1-cache-${{ hashFiles('backend/stack.yaml.lock') }}
restore-keys: |
buildkit-1-cache-
- name: Load buildkit cache from github cache
uses: dashevo/gh-action-cache-buildkit-state@v1
with:
builder: buildx_buildkit_${{ steps.buildx.outputs.name }}0
cache-path: /tmp/buildkit-cache
cache-max-size: 2g
- name: Build container
run: |
docker buildx build \
--cache-from "type=local,src=/tmp/docker-cache" \
--cache-to "type=local,dest=/tmp/docker-cache,mode=max" \
--output "type=docker" \
--tag play/futulog:$(git rev-parse --short HEAD) .
- name: Deploy to futuEKS
run: |
echo "$KUBE_YAML" > kubeconfig
REPO=$(aws ecr describe-repositories --repository-names play/futulog --region=eu-central-1 --query "repositories[0].repositoryUri" --output text)
export REPO
ECR_PASSWORD=$(aws ecr get-login-password --region eu-central-1)
export ECR_PASSWORD
R=$(aws sts assume-role --role-arn "$AWS_ROLE_TO_ASSUME" --role-session-name AWSCLI-Session)
export AWS_ACCESS_KEY_ID=$(echo "$R"|jq -r '.Credentials.AccessKeyId')
export AWS_SECRET_ACCESS_KEY=$(echo "$R"|jq -r '.Credentials.SecretAccessKey')
export AWS_SESSION_TOKEN=$(echo "$R"|jq -r '.Credentials.SessionToken')
./deploy.sh cd
if: github.ref == 'refs/heads/master'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
KUBE_YAML: ${{ secrets.KUBE_YAML }}
AWS_DEFAULT_REGION: eu-central-1
KUBECONFIG: kubeconfig