-
Notifications
You must be signed in to change notification settings - Fork 30
146 lines (142 loc) · 4.46 KB
/
Main.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Main
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
platform: [scalable]
runs-on: ${{ matrix.platform }}
env:
ENV: dev
PRIVATE_ECR_URL: 358484141435.dkr.ecr.us-west-2.amazonaws.com
PUBLIC_ECR_URL: public.ecr.aws/k6m5b6e2
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-east-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
- name: Prepare key
shell: bash
run: |
tar -C ~/.ssh -zcf key.tar.gz ./
- name: Clean garbage containers and images
shell: bash
run: |
docker rm $(docker ps -a | grep -v "^CONTAINER" | awk '{print $1}') || true
docker rmi -f $(docker images -f "dangling=true" -q) || true
- name: Build rust base image
shell: bash
run: |
make ci_build_binary_rust_base
- name: Build binary image
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
shell: bash
run: |
COMMIT_HASH=$(echo ${GITHUB_CONTEXT} | jq '.event.pull_request.head.sha')
if [ "${COMMIT_HASH}" == "null" ]; then
export COMMIT_HASH="${GITHUB_SHA}"
else
export COMMIT_HASH=${COMMIT_HASH}
fi
export BRANCH="${GITHUB_HEAD_REF}"
export TOBRANCH="main"
export IMAGE_TAG="${TOBRANCH}-${COMMIT_HASH}"
export VERGEN_SHA_EXTERN="${IMAGE_TAG}"
echo "Image tag: ${IMAGE_TAG}"
make ci_build_release_binary_image
- name: Build findorad images
env:
PRIVATE_ECR_URL: ${{ env.PRIVATE_ECR_URL }}
PUBLIC_ECR_URL: ${{ env.PUBLIC_ECR_URL }}
ENV: ${{ env.ENV }}
GITHUB_CONTEXT: ${{ toJSON(github) }}
shell: bash
run: |
COMMIT_HASH=$(echo ${GITHUB_CONTEXT} | jq '.event.pull_request.head.sha')
if [ "${COMMIT_HASH}" == "null" ]; then
export COMMIT_HASH="${GITHUB_SHA}"
else
export COMMIT_HASH=${COMMIT_HASH}
fi
export BRANCH="${GITHUB_HEAD_REF}"
export TOBRANCH="main"
export IMAGE_TAG="${TOBRANCH}-${COMMIT_HASH}"
echo "Image tag: ${IMAGE_TAG}"
make ci_build_image
- name: Push images
env:
PRIVATE_ECR_URL: ${{ env.PRIVATE_ECR_URL }}
PUBLIC_ECR_URL: ${{ env.PUBLIC_ECR_URL }}
ENV: ${{ env.ENV }}
GITHUB_CONTEXT: ${{ toJSON(github) }}
shell: bash
run: |
COMMIT_HASH=$(echo ${GITHUB_CONTEXT} | jq '.event.pull_request.head.sha')
if [ "${COMMIT_HASH}" == "null" ]; then
export COMMIT_HASH="${GITHUB_SHA}"
else
export COMMIT_HASH=${COMMIT_HASH}
fi
export BRANCH="${GITHUB_HEAD_REF}"
export TOBRANCH="main"
export IMAGE_TAG="${TOBRANCH}-${COMMIT_HASH}"
echo "Image tag: ${IMAGE_TAG}"
make ci_push_image
- name: Clean images
env:
PRIVATE_ECR_URL: ${{ env.PRIVATE_ECR_URL }}
PUBLIC_ECR_URL: ${{ env.PUBLIC_ECR_URL }}
ENV: ${{ env.ENV }}
GITHUB_CONTEXT: ${{ toJSON(github) }}
shell: bash
run: |
COMMIT_HASH=$(echo ${GITHUB_CONTEXT} | jq '.event.pull_request.head.sha')
if [ "${COMMIT_HASH}" == "null" ]; then
export COMMIT_HASH="${GITHUB_SHA}"
else
export COMMIT_HASH=${COMMIT_HASH}
fi
export BRANCH="${GITHUB_HEAD_REF}"
export TOBRANCH="main"
export IMAGE_TAG="${TOBRANCH}-${COMMIT_HASH}"
echo "Image tag: ${IMAGE_TAG}"
make clean_image
- name: Clean binary images
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
shell: bash
run: |
COMMIT_HASH=$(echo ${GITHUB_CONTEXT} | jq '.event.pull_request.head.sha')
if [ "${COMMIT_HASH}" == "null" ]; then
export COMMIT_HASH="${GITHUB_SHA}"
else
export COMMIT_HASH=${COMMIT_HASH}
fi
export BRANCH="${GITHUB_HEAD_REF}"
export TOBRANCH="main"
export IMAGE_TAG="${TOBRANCH}-${COMMIT_HASH}"
echo "Image tag: ${IMAGE_TAG}"
make clean_binary_dockerhub
- name: Clean garbage
shell: bash
run: |
rm -rf /tmp/*>/dev/null 2>&1 || true