-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (128 loc) · 4.71 KB
/
ci.yml
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
name: Continuous Integration
on:
push:
schedule:
- cron: '0 17 * * *' # 3 AM AEST
jobs:
image:
runs-on:
- ${{ matrix.arch }}
- linux
- self-hosted
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v6
with:
file: ${{ matrix.version }}/Dockerfile
no-cache: ${{ github.event_name == 'schedule' }}
push: true
tags: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}:sha-${{ github.sha }}-${{ matrix.version }}-${{ matrix.arch }}
strategy:
matrix:
arch:
- arm64
- x64
version:
- 7
manifest:
env:
IMAGE_REPO: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}
IMAGE_TAG: sha-${{ github.sha }}-${{ matrix.version }}
needs: image
runs-on:
- linux
- self-hosted
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push branch manifest list
run: |
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:${GITHUB_REF#refs/heads/}-${{ matrix.version }} \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Push SHA manifest list
run: |
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Push version manifest list
if: github.ref == 'refs/heads/master'
run: |
# Version.
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:${{ matrix.version }} \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Push 'latest' manifest list
if: github.ref == 'refs/heads/master' && matrix.version == '7'
run: |
# Latest.
docker buildx imagetools create -t \
${{ env.IMAGE_REPO }}:latest \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-arm64 \
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}-x64
- name: Remove arch tags
run: |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "${{ secrets.DOCKER_USERNAME }}", "password": "${{ secrets.DOCKER_PASSWORD }}"}' "https://hub.docker.com/v2/users/login/" | jq -r '.token')
curl "https://hub.docker.com/v2/repositories/${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}/tags/${{ env.IMAGE_TAG }}-arm64/" -X DELETE -H "Authorization: JWT ${TOKEN}"
curl "https://hub.docker.com/v2/repositories/${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}/tags/${{ env.IMAGE_TAG }}-x64/" -X DELETE -H "Authorization: JWT ${TOKEN}"
strategy:
matrix:
version:
- 7
image-x64:
env:
IMAGE_REPO: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}
IMAGE_TAG: sha-${{ github.sha }}-${{ matrix.version }}
runs-on:
- linux
- self-hosted
- x64
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/build-push-action@v6
with:
file: ${{ matrix.version }}/Dockerfile
no-cache: ${{ github.event_name == 'schedule' }}
push: true
tags: ${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}
- name: Push branch tag
run: |
docker tag ${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} ${{ env.IMAGE_REPO }}:${GITHUB_REF#refs/heads/}-${{ matrix.version }}
docker push ${{ env.IMAGE_REPO }}:${GITHUB_REF#refs/heads/}-${{ matrix.version }}
- name: Push version tag
if: github.ref == 'refs/heads/master'
run: |
docker tag ${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }} ${{ env.IMAGE_REPO }}:${{ matrix.version }}
docker push ${{ env.IMAGE_REPO }}:${{ matrix.version }}
strategy:
matrix:
version:
- 1
- 1-alpine
- 2.4
- 2.4-alpine
- 5
- 5-alpine
- 6
readme:
needs: manifest
runs-on:
- self-hosted
steps:
- uses: actions/checkout@v2
- uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPO }}