Skip to content

Commit d3edf69

Browse files
authored
Update main.yml
1 parent 45940fc commit d3edf69

File tree

1 file changed

+15
-80
lines changed

1 file changed

+15
-80
lines changed

Diff for: .github/workflows/main.yml

+15-80
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,19 @@ on:
1212

1313
# Allows you to run this workflow manually from the Actions tab
1414
workflow_dispatch:
15-
16-
env:
17-
REGISTRY_IMAGE: server-bot-rust
18-
15+
1916
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2017
jobs:
2118
# This workflow contains a single job called "build"
2219
build:
2320
# The type of runner that the job will run on
2421
runs-on: ubuntu-latest
25-
strategy:
26-
matrix:
27-
platform:
28-
- linux/amd64
29-
- linux/arm64
3022

3123
# Steps represent a sequence of tasks that will be executed as part of the job
3224
steps:
3325
- name: Checkout
3426
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+
4728
- name: Set up QEMU
4829
uses: docker/setup-qemu-action@v3
4930

@@ -58,64 +39,18 @@ jobs:
5839
username: ${{ github.actor }}
5940
password: ${{ secrets.GITHUB_TOKEN }}
6041

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
7844
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-
8348

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

Comments
 (0)