12
12
13
13
# Allows you to run this workflow manually from the Actions tab
14
14
workflow_dispatch :
15
-
16
- env :
17
- REGISTRY_IMAGE : server-bot-rust
18
-
15
+
19
16
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
20
17
jobs :
21
18
# This workflow contains a single job called "build"
22
19
build :
23
20
# The type of runner that the job will run on
24
21
runs-on : ubuntu-latest
25
- strategy :
26
- matrix :
27
- platform :
28
- - linux/amd64
29
- - linux/arm64
30
22
31
23
# Steps represent a sequence of tasks that will be executed as part of the job
32
24
steps :
33
25
- name : Checkout
34
26
uses : actions/checkout@v4
35
-
36
- - name : Prepare
37
- run : |
38
- platform=${{ matrix.platform }}
39
- echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
40
-
41
- - name : Docker meta
42
- id : meta
43
- uses : docker/metadata-action@v5
44
- with :
45
- images : ${{ env.REGISTRY_IMAGE }}
46
-
27
+
47
28
- name : Set up QEMU
48
29
uses : docker/setup-qemu-action@v3
49
30
@@ -58,64 +39,18 @@ jobs:
58
39
username : ${{ github.actor }}
59
40
password : ${{ secrets.GITHUB_TOKEN }}
60
41
61
- - name : Build and push by digest
62
- id : build
63
- uses : docker/build-push-action@v6
64
- with :
65
- platforms : ${{ matrix.platform }}
66
- labels : ${{ steps.meta.outputs.labels }}
67
- outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
68
- tags : ghcr.io/${{ github.repository }}/server-bot-rust:latest
69
-
70
- - name : Export digest
71
- run : |
72
- mkdir -p /tmp/digests
73
- digest="${{ steps.build.outputs.digest }}"
74
- touch "/tmp/digests/${digest#sha256:}"
75
-
76
- - name : Upload digest
77
- uses : actions/upload-artifact@v4
42
+ - name : Cache Docker layers
43
+ uses : actions/cache@v3
78
44
with :
79
- name : digests-${{ env.PLATFORM_PAIR }}
80
- path : /tmp/digests/*
81
- if-no-files-found : error
82
- retention-days : 1
45
+ path : /tmp/.buildx-cache
46
+ key : ${{ runner.os }}-buildx-${{ github.sha }}
47
+ restore-keys : ${{ runner.os }}-buildx-
83
48
84
- merge :
85
- runs-on : ubuntu-latest
86
- needs :
87
- - build
88
- steps :
89
- - name : Download digests
90
- uses : actions/download-artifact@v4
91
- with :
92
- path : /tmp/digests
93
- pattern : digests-*
94
- merge-multiple : true
95
-
96
- - name : Set up Docker Buildx
97
- uses : docker/setup-buildx-action@v3
98
-
99
- - name : Docker meta
100
- id : meta
101
- uses : docker/metadata-action@v5
102
- with :
103
- images : ${{ env.REGISTRY_IMAGE }}
104
-
105
- - name : Login to Registry
106
- uses : docker/login-action@v3
107
- with :
108
- # registry: docker.pkg.github.com
109
- registry : ghcr.io
110
- username : ${{ github.actor }}
111
- password : ${{ secrets.GITHUB_TOKEN }}
112
-
113
- - name : Create manifest list and push
114
- working-directory : /tmp/digests
115
- run : |
116
- docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
117
- $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
118
-
119
- - name : Inspect image
120
- run : |
121
- docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
49
+ - uses : docker/build-push-action@v5
50
+ with :
51
+ context : .
52
+ platforms : linux/amd64,linux/arm64
53
+ push : true
54
+ tags : ghcr.io/${{ github.repository }}/server-bot-rust:latest
55
+ cache-from : type=gha
56
+ cache-to : type=gha,mode=max
0 commit comments