-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (111 loc) · 3.98 KB
/
Copy pathci.yml
File metadata and controls
128 lines (111 loc) · 3.98 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
name: ci
on:
workflow_dispatch:
# push:
# branches:
# - 'releases/v*'
# - 'develop'
# tags:
# - 'v*.*.*'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
docker:
runs-on: [self-hosted, multiarch]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set usefull environment variables
run: echo REPOSITORY_NAME=${GITHUB_REPOSITORY#*\/} >> $GITHUB_ENV
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
"${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY_NAME }}"
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.description=A test for Docker CI with Github Actions.
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Add SSH Key to agent (for buildx nodes communication)
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[registry."docker.io"]
mirrors = ["${{ secrets.DOCKERHUB_PROXY_HOSTNAME }}"]
driver-opts: |
network=host
buildkitd-flags: |
--debug
--allow-insecure-entitlement network.host
--allow-insecure-entitlement security.insecure
endpoint: ssh://bruno@pc-bruno-gpu
platforms: linux/amd64
append: |
- endpoint: ssh://bruno@mbp-bruno
platforms: linux/arm64/v8
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: |
linux/amd64
linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: "${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPOSITORY_NAME }}"
create-manifests:
runs-on: [self-hosted]
needs: [build-push-x64, build-push-arm64]
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
...
- name: Create SHA manifest and push
run: |
docker manifest create \
compute-lsis-2/my-repo:${{ github.sha }} \
--amend my-registry/my-repo:${{ github.sha }}-amd64 \
--amend my-registry/my-repo:${{ github.sha }}-armv7 \
--amend my-registry/my-repo:${{ github.sha }}-arm64
docker manifest push my-registry/my-repo:${{ github.sha }}
- name: Create latest manifest and push
run: |
docker manifest create \
my-registry/my-repo:latest \
--amend my-registry/my-repo:latest-amd64 \
--amend my-registry/my-repo:latest-armv7 \
--amend my-registry/my-repo:latest-arm64
docker manifest push my-registry/my-repo:latest