-
Notifications
You must be signed in to change notification settings - Fork 5
202 lines (173 loc) · 6.52 KB
/
buildcontainer.yml
File metadata and controls
202 lines (173 loc) · 6.52 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Build Docker Image
on:
push:
tags:
- "v*.*.*"
pull_request:
branches:
- "*"
env:
AWS_REGION: us-east-1
jobs:
build_image:
name: build_image
permissions:
id-token: write
contents: read
runs-on: 'ubicloud-standard-4'
steps:
- name: Remove unused tools
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Clone the current repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository}}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-03-02
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Print rustc cfg
run: rustc --print cfg
- name: Build and run binary
run: |
cargo build --release --target x86_64-unknown-linux-gnu
mkdir -p bin
mv target/x86_64-unknown-linux-gnu/release/o2_report_generator bin/report-generator
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058694856476:role/GitHubActionsRole
role-session-name: GithubActionsSession
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set GIT_TAG env
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
tags: |
public.ecr.aws/zinclabs/report-server:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
build_pr_image_arm:
name: build_pr_image_arm
permissions:
id-token: write
contents: read
runs-on: 'ubicloud-standard-4-arm'
steps:
- name: Remove unused tools
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Clone the current repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository}}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-03-02
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Print rustc cfg
run: rustc --print cfg
- name: Build and run binary
run: |
cargo build --release --target aarch64-unknown-linux-gnu
mkdir -p bin
mv target/aarch64-unknown-linux-gnu/release/o2_report_generator bin/report-generator
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058694856476:role/GitHubActionsRole
role-session-name: GithubActionsSession
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set GIT_TAG env
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
tags: |
public.ecr.aws/zinclabs/report-server:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64
build:
needs: [build_image, build_pr_image_arm]
runs-on: ubicloud-standard-2-arm
permissions:
id-token: write
contents: read
steps:
- name: Clone the current repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository}}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Set GIT_TAG env
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058694856476:role/GitHubActionsRole
role-session-name: GithubActionsSession
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- uses: int128/docker-manifest-create-action@v2
with:
tags: |
public.ecr.aws/zinclabs/report-server:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}
sources: |
public.ecr.aws/zinclabs/report-server:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-amd64
public.ecr.aws/zinclabs/report-server:${{ env.GIT_TAG }}-${{ env.GIT_HASH}}-arm64