-
Notifications
You must be signed in to change notification settings - Fork 8
148 lines (133 loc) · 4.72 KB
/
docker.yml
File metadata and controls
148 lines (133 loc) · 4.72 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
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Docker Image
on:
push:
branchs:
- master
schedule:
- cron: '0 0 * * 1'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_IMAGE_REPOSITORY: ghcr.io/${{ github.repository }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_ACCESSTOKEN }}
DOCKERHUB_IMAGE_REPOSITORY: yansongda/php
ALIYUN_IMAGE_TOKEN: ${{ secrets.ALIYUN_IMAGE_ACCESSTOKEN }}
ALIYUN_IMAGE_REPOSITORY: registry.cn-shenzhen.aliyuncs.com/yansongda/php
jobs:
build:
name: Image ${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}-${{ matrix.platform }}
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
fail-fast: false
matrix:
php-version:
# - '8.5'
- '8.4'
- '8.3'
- '8.2'
php-mode:
- cli
system:
- alpine
- trixie
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Recognize tag
run: |
platform=$(echo ${{ matrix.platform }} | sed 's/linux\///g')
tag=$platform'-'${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}
echo $tag
echo "tag=$tag" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- name: Build the docker image
run: |
docker buildx ls
docker buildx build -t app --platform ${{ matrix.platform }} -f ./${{ matrix.php-version }}/${{ matrix.php-mode }}/${{ matrix.system }}/Dockerfile ./${{ matrix.php-version }}/${{ matrix.php-mode }}
- name: Push the image to Aliyun registry
run: |
docker tag app $ALIYUN_IMAGE_REPOSITORY:$tag
echo $ALIYUN_IMAGE_TOKEN | docker login --username=yansongda registry.cn-shenzhen.aliyuncs.com --password-stdin
docker push $ALIYUN_IMAGE_REPOSITORY:$tag
docker logout
- name: Push the image to Docker registry
run: |
docker tag app $DOCKERHUB_IMAGE_REPOSITORY:$tag
echo $DOCKERHUB_TOKEN | docker login --username yansongda --password-stdin
docker push $DOCKERHUB_IMAGE_REPOSITORY:$tag
docker logout
- name: Push the image to Github registry
run: |
docker tag app $GITHUB_IMAGE_REPOSITORY:$tag
echo $GITHUB_TOKEN | docker login --username=${{ github.actor }} ghcr.io --password-stdin
docker push $GITHUB_IMAGE_REPOSITORY:$tag
docker logout
manifest:
name: Manifest ${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
php-version:
# - '8.5'
- '8.4'
- '8.3'
- '8.2'
php-mode:
- cli
system:
- alpine
- trixie
env:
PLATFORMS: "linux/arm64 linux/amd64"
steps:
- name: Recognize manifest
run: |
tag=${{ matrix.php-mode }}-${{ matrix.php-version }}-${{ matrix.system }}
echo $tag
echo "tag=$tag" >> $GITHUB_ENV
- name: Push the manifest to Aliyun registry
run: |
echo $ALIYUN_IMAGE_TOKEN | docker login --username=yansongda registry.cn-shenzhen.aliyuncs.com --password-stdin
list=$(echo $PLATFORMS | sed 's/linux\///g')
aliyun=''
for platform in $list;
do
aliyun=$aliyun$ALIYUN_IMAGE_REPOSITORY':'$platform'-'$tag' '
done
docker manifest create $ALIYUN_IMAGE_REPOSITORY:$tag $aliyun
docker manifest push $ALIYUN_IMAGE_REPOSITORY:$tag
docker logout
- name: Push the manifest to Docker registry
run: |
echo $DOCKERHUB_TOKEN | docker login --username yansongda --password-stdin
list=$(echo $PLATFORMS | sed 's/linux\///g')
hub=''
for platform in $list;
do
hub=$hub$DOCKERHUB_IMAGE_REPOSITORY':'$platform'-'$tag' '
done
docker manifest create $DOCKERHUB_IMAGE_REPOSITORY:$tag $hub
docker manifest push $DOCKERHUB_IMAGE_REPOSITORY:$tag
docker logout
- name: Push the manifest to Github registry
run: |
echo $GITHUB_TOKEN | docker login --username=${{ github.actor }} ghcr.io --password-stdin
list=$(echo $PLATFORMS | sed 's/linux\///g')
github=''
for platform in $list;
do
github=$github$GITHUB_IMAGE_REPOSITORY':'$platform'-'$tag' '
done
docker manifest create $GITHUB_IMAGE_REPOSITORY:$tag $github
docker manifest push $GITHUB_IMAGE_REPOSITORY:$tag
docker logout