-
Notifications
You must be signed in to change notification settings - Fork 4
135 lines (119 loc) 路 5.43 KB
/
Copy pathdocker-buildx.yml
File metadata and controls
135 lines (119 loc) 路 5.43 KB
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
133
134
135
#@doc
# * This GitHub Actions workflow builds and pushes a Docker image to GitHub Container Registry.
# * It is triggered when a branch is created with the name syntax "release/[version]-[channel]".
#
# The workflow does the following:
# 1. Checks out the code, sets up Docker buildx, Login to the registry.
# 2. Extracts the branch name from the GITHUB_REF environment variable.
# 3. Splits the branch name to get the version and channel.
# 4. Builds and pushes the Docker image.
# Examples:
# If the branch name is 'release/1.0.0-latest', the image is tagged as '1.0.0' and 'latest'.
# If the branch name is 'release/1.0.1-stable', the image is tagged as '1.0.1' and 'stable'.
# If the branch name is 'release/1.0.2-dev', the image is tagged as '1.0.2-dev'.
#
# * The 'latest' and 'stable' tags allow us to easily switch between different versions.
# * The 'dev' tag allows you to have a separate version for development.
name: Docker Images
on:
workflow_dispatch:
push:
branches:
- "release/*"
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
docker:
name: Build & push images
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version and release type
id: extract_version
run: |
BRANCH_NAME=${{ github.ref_name }}
VERSION=$(echo $BRANCH_NAME | cut -d'/' -f 2 | cut -d'-' -f 1)
RELEASE_TYPE=$(echo $BRANCH_NAME | cut -d'/' -f 2 | cut -d'-' -f 2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
- name: Docker meta for mewbo-base
id: meta_base
uses: docker/metadata-action@v5
with:
images: ghcr.io/bearlike/mewbo-base
tags: |
type=raw,value=${{ steps.extract_version.outputs.version }}${{ steps.extract_version.outputs.release_type == 'dev' && '-dev' || '' }}
type=raw,value=latest,enable=${{ steps.extract_version.outputs.release_type == 'latest' }}
type=raw,value=stable,enable=${{ steps.extract_version.outputs.release_type == 'stable' }}
type=raw,value=dev,enable=${{ steps.extract_version.outputs.release_type == 'dev' }}
- name: Docker meta for mewbo-console
id: meta_console
uses: docker/metadata-action@v5
with:
images: ghcr.io/bearlike/mewbo-console
tags: |
type=raw,value=${{ steps.extract_version.outputs.version }}${{ steps.extract_version.outputs.release_type == 'dev' && '-dev' || '' }}
type=raw,value=latest,enable=${{ steps.extract_version.outputs.release_type == 'latest' }}
type=raw,value=stable,enable=${{ steps.extract_version.outputs.release_type == 'stable' }}
type=raw,value=dev,enable=${{ steps.extract_version.outputs.release_type == 'dev' }}
- name: Docker meta for mewbo-api
id: meta_api
uses: docker/metadata-action@v5
with:
images: ghcr.io/bearlike/mewbo-api
tags: |
type=raw,value=${{ steps.extract_version.outputs.version }}${{ steps.extract_version.outputs.release_type == 'dev' && '-dev' || '' }}
type=raw,value=latest,enable=${{ steps.extract_version.outputs.release_type == 'latest' }}
type=raw,value=stable,enable=${{ steps.extract_version.outputs.release_type == 'stable' }}
type=raw,value=dev,enable=${{ steps.extract_version.outputs.release_type == 'dev' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push mewbo-base
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.base
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_base.outputs.tags }}
labels: ${{ steps.meta_base.outputs.labels }}
build-args: |
VERSION=${{ steps.extract_version.outputs.version }}
- name: Build and push mewbo-console
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.console
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_console.outputs.tags }}
labels: ${{ steps.meta_console.outputs.labels }}
build-args: |
VERSION=${{ steps.extract_version.outputs.version }}
- name: Build and push mewbo-api
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.api
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_api.outputs.tags }}
labels: ${{ steps.meta_api.outputs.labels }}
build-args: |
VERSION=${{ steps.extract_version.outputs.version }}
BASE_IMAGE=ghcr.io/bearlike/mewbo-base:${{ steps.extract_version.outputs.version }}${{ steps.extract_version.outputs.release_type == 'dev' && '-dev' || '' }}