forked from misskey-dev/misskey
-
-
Notifications
You must be signed in to change notification settings - Fork 6
132 lines (117 loc) · 4.85 KB
/
docker-publish.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Publish Docker image
run-name: Publish Docker image (${{ github.ref_type == 'tag' && github.ref_name || 'nightly' }})
on:
push:
branches:
- taiyme
tags:
- '*-taiyme.*'
permissions:
contents: read
packages: write
id-token: write
jobs:
build-and-push:
name: Build and Push
runs-on: ${{ matrix.value.os }}
strategy:
fail-fast: false
matrix:
value:
- os: ubuntu-22.04
platform: linux/amd64
- os: ubuntu-22.04-arm
platform: linux/arm64
steps:
- name: Checkout ${{ github.sha }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
ref: ${{ github.sha }}
fetch-depth: 1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 9
with:
images: ${{ vars.DOCKER_IMAGE_NAME }}
tags: |
type=raw,priority=1300,value=${{ github.ref_name }},prefix=,suffix=,enable=${{ github.ref_type == 'tag' }}
type=raw,priority=1200,value=latest,prefix=,suffix=,enable=${{ github.ref_type == 'tag' }}
type=raw,priority=1200,value=nightly,prefix=,suffix=,enable=${{ github.ref_type != 'tag' }}
type=sha,priority=1100,format=short,prefix=,suffix=,enable=true
- name: Build and Push by digest
id: build
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
context: .
push: true
platforms: ${{ matrix.value.platform }}
provenance: false
annotations: ${{ steps.meta.outputs.annotations }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=platform-${{ runner.os }}-${{ runner.arch }}
cache-to: type=gha,mode=max,scope=platform-${{ runner.os }}-${{ runner.arch }}
outputs: type=image,name=${{ vars.DOCKER_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
env:
digest: ${{ steps.build.outputs.digest }}
run: |
mkdir -p ${{ runner.temp }}/digests
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: digests-${{ runner.os }}-${{ runner.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge-images:
name: Merge images
runs-on: ubuntu-22.04
needs:
- build-and-push
steps:
- name: Download digests
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
pattern: digests-*
path: ${{ runner.temp }}/digests
merge-multiple: true
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 9
with:
images: ${{ vars.DOCKER_IMAGE_NAME }}
tags: |
type=raw,priority=1300,value=${{ github.ref_name }},prefix=,suffix=,enable=${{ github.ref_type == 'tag' }}
type=raw,priority=1200,value=latest,prefix=,suffix=,enable=${{ github.ref_type == 'tag' }}
type=raw,priority=1200,value=nightly,prefix=,suffix=,enable=${{ github.ref_type != 'tag' }}
type=sha,priority=1100,format=short,prefix=,suffix=,enable=true
- name: Create and Push manifest list
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ vars.DOCKER_IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ vars.DOCKER_IMAGE_NAME }}:${{ steps.meta.outputs.version }}