@@ -19,15 +19,14 @@ defaults:
19
19
run :
20
20
shell : bash
21
21
22
- env :
23
- CI : true
24
- DOCKER_BUILDKIT : 1
25
-
26
22
jobs :
27
23
build :
28
24
runs-on : ubuntu-latest
29
25
env :
30
- BUILDKIT_INLINE_CACHE : 1
26
+ CACHE_IMAGE : " ghcr.io/ibm/text-gen-router:build-cache"
27
+ CACHE_REGISTRY : " ghcr.io"
28
+ QUAY_REPOSITORY : " quay.io/wxpe/text-gen-router"
29
+
31
30
permissions :
32
31
packages : write
33
32
contents : read
46
45
username : ${{ github.actor }}
47
46
password : ${{ secrets.GITHUB_TOKEN }}
48
47
49
- - name : " Docker build"
50
- run : make build-router
48
+ - name : " Log in to quay"
49
+ uses : docker/login-action@v3
50
+ with :
51
+ registry : quay.io
52
+ username : wxpe+github_pusher_bot
53
+ password : ${{ secrets.WXPE_QUAY_TOKEN }}
51
54
52
- - name : " Docker push"
53
- if : github.ref == 'refs/heads/main'
54
- run : make push-router-image
55
+ - name : " Set build cache target"
56
+ run : |
57
+ # For push to `main` (PR merged), push a new cache image with all layers (cache-mode=max).
58
+ # For PR builds, use GitHub action cache which isolates cached layers by PR/branch.
59
+ # to optimize builds for subsequent pushes to the same PR/branch.
60
+ # Do not set a cache-to image for PR builds to not overwrite the `main` cache image and
61
+ # to not ping-pong cache images for two or more different PRs.
62
+ # Do not push cache images for each PR or multiple branches to not exceed GitHub package
63
+ # usage and traffic limitations.
64
+ # UPDATE 2024/02/26: GHA cache appears to have issues, cannot use `cache-to: gha,mode=min`
65
+ # if `cache-from: reg...,mode=max` but `cache-to: gha,mode=max` takes longer than uncached
66
+ # build and exhausts GHA cache size limits, so use cache `type=inline` (no external cache).
67
+ if [ "${{ github.event_name }}" == "pull_request" ]
68
+ then
69
+ #CACHE_TO="type=gha,mode=min"
70
+ CACHE_TO="type=inline"
71
+ else
72
+ CACHE_TO="type=registry,ref=${{ env.CACHE_IMAGE }},mode=max"
73
+ fi
74
+ echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
75
+
76
+ - name : " push tags"
77
+ run : echo "PUSH_TAGS=$(scripts/get_image_tags.sh ${QUAY_REPOSITORY} | tr -s '[:blank:]' ',')" >> $GITHUB_ENV
78
+
79
+ - name : " Build and push"
80
+ uses : docker/build-push-action@v5
81
+ with :
82
+ context : .
83
+ target : router-release
84
+ tags : ${{ env.PUSH_TAGS }}
85
+ cache-from : type=registry,ref=${{ env.CACHE_IMAGE }}
86
+ cache-to : ${{ env.CACHE_TO }}
87
+ push : ${{ github.event_name != 'pull_request' }}
88
+ platforms : linux/amd64
0 commit comments