107 lines (100 loc) · 3.15 KB
/
release.yaml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: publish container image
on:
push:
branches:
- main
permissions:
packages: write
contents: read
jobs:
build:
name: Build and Publish image
strategy:
fail-fast: true
matrix:
runs-on:
- "ubuntu-latest"
- "buildjet-2vcpu-ubuntu-2204-arm"
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: "azuki-bar"
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare-tag
id: tags
run: |
arch=""
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
case "${{ runner.arch }}" in
"X64" ) arch="amd64" ;;
"ARM64" ) arch="arm64" ;;
esac
echo "tag=${{ github.sha }}-${arch}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/azuki-bar/hello-buildjet-nextjs:${{ steps.tags.outputs.tag }}
provenance: false
merge-images:
runs-on: "ubuntu-latest"
needs: ["build"]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: "azuki-bar"
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create a New Image
run: |
image_tag="ghcr.io/azuki-bar/hello-buildjet-nextjs:${{ github.sha }}"
docker buildx imagetools create --dry-run \
--tag ${image_tag} \
${image_tag}-arm64 \
${image_tag}-amd64
docker buildx imagetools create \
--tag ${image_tag} \
${image_tag}-arm64 \
${image_tag}-amd64
- name: Check New Manifests
run: |
image_tag="ghcr.io/azuki-bar/hello-buildjet-nextjs:${{ github.sha }}"
# 表示用
docker buildx imagetools inspect ${image_tag}
docker buildx imagetools inspect ${image_tag} --format "{{json .Image}}" \
| jq -e '. | keys | contains(["linux/amd64", "linux/arm64"])'
build-with-qemu:
name: Build and Publish image with QEMU
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: "azuki-bar"
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/azuki-bar/hello-buildjet-nextjs:${{ github.sha }}-qemu
platforms: linux/amd64,linux/arm64
provenance: false