-
Notifications
You must be signed in to change notification settings - Fork 20
62 lines (55 loc) · 2.04 KB
/
build-and-push-dev-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
name: build and publish dev image
on:
push:
branches:
# this workflow create dev-only image for every push to the main branch
- main
# unlike other workflow, we don't cancel in progress jobs of this workflow if multiple push events happen
env:
REGISTRY: ghcr.io
PROXY_IMAGE_NAME: ghcr.io/mosn/htnn-proxy
CONTROLLER_IMAGE_NAME: ghcr.io/mosn/htnn-controller
jobs:
build-and-push-image:
if: github.repository == 'mosn/htnn'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# for the go commands in `make prebuild`
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache-dependency-path: "**/*.sum"
# The built image can be found in:
# https://github.com/mosn/htnn/pkgs/container/htnn-controller
# https://github.com/mosn/htnn/pkgs/container/htnn-proxy
- name: Build and push Docker image
run: |
make prebuild
cd ./manifests
# push image with the dev tag
export PROXY_IMAGE=${{ env.PROXY_IMAGE_NAME }}:dev
export CONTROLLER_IMAGE=${{ env.CONTROLLER_IMAGE_NAME }}:dev
make build-proxy-image
make build-controller-image
make push-image
# push image with unique tag
SHA=$(git rev-parse HEAD)
UNIQUE_TAG=dev-${SHA}
docker tag ${{ env.PROXY_IMAGE_NAME }}:dev ${{ env.PROXY_IMAGE_NAME }}:$UNIQUE_TAG
docker tag ${{ env.CONTROLLER_IMAGE_NAME }}:dev ${{ env.CONTROLLER_IMAGE_NAME }}:$UNIQUE_TAG
export PROXY_IMAGE=${{ env.PROXY_IMAGE_NAME }}:$UNIQUE_TAG
export CONTROLLER_IMAGE=${{ env.CONTROLLER_IMAGE_NAME }}:$UNIQUE_TAG
make push-image