-
Notifications
You must be signed in to change notification settings - Fork 39
86 lines (82 loc) · 2.65 KB
/
build_image.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
name: Build docker image
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
dispatch:
type: string
description: "The tag name for docker images"
required: true
jobs:
output_tag_name:
runs-on: ubuntu-22.04
outputs:
tag_name: ${{ steps.output.outputs.tag_name }}
steps:
- name: output tag name for image
id: output
run: |
if [ ${{ github.event_name }} == 'push' ]; then
export tag_name=`echo ${{ github.ref }} | awk -F '/' '{print $3}'`
fi
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
export tag_name=${{ github.event.inputs.dispatch }}
fi
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
build-amd64-image:
runs-on: ubuntu-22.04
needs: output_tag_name
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref || 'main' }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: axonweb3/axon:amd64-${{ needs.output_tag_name.outputs.tag_name }}
build-arm64-image:
runs-on: [self-hosted, build]
needs: output_tag_name
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_EC2_TYPE: "c6g.xlarge"
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
AXON_TAG: arm64-${{needs.output_tag_name.outputs.tag_name}}
steps:
- name: Get Current Date & Set ENV
id: date
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref || 'build-arm64-image' }}
- name: arm64 docker image build
env:
JOB_ID: "build-arm64-image-${{ github.repository_owner }}-${{ steps.date.outputs.date }}-in-10h"
run: |
./devtools/ci/build-arm64.sh run
- name: clean up
if: ${{ always() }}
env:
JOB_ID: "build-arm64-image-${{ github.repository_owner }}-${{ steps.date.outputs.date }}-in-10h"
run: |
./devtools/ci/build-arm64.sh clean