-
-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (105 loc) · 3.95 KB
/
docker-cicd-develop.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
name: "Docker CI (image development)"
env:
# Change this to match GITHUB_REPOSITORY or any name you want.
# But please be reminded that Docker images only support
# lowercased letters as as long as there's an label called
# org.opencontainers.image.source.
repository: starter-pack
namespace: code-server-boilerplates
namespace_dockerhub: codeserverboilerplates
on:
push:
paths:
- "Dockerfile"
- ".trigger-rebuild"
- ".dockerignore"
- "toolkits/packages/scripts/**"
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
force_push:
description: Leave it blank to only run test build, otherwise set to true.
required: false
jobs:
test-image-builds:
name: Test and analyize image build
runs-on: "ubuntu-latest"
steps:
- name: "Create checkmates"
uses: "actions/checkout@v2"
- name: Install Dive
run: |
wget https://github.com/wagoodman/dive/releases/download/v0.10.0/dive_0.10.0_linux_amd64.deb -O /tmp/dive_linux_amd64.deb
sudo apt install /tmp/dive_linux_amd64.deb
- name: Build and check for wasted space
env:
DOCKER_BUILDKIT: 1
run: |
set -eux
docker build --tag registry.repohub.dev/${{env.namespace}}/${{env.repository}} .
CI=true dive registry.repohub.dev/${{env.namespace}}/${{env.repository}}
publish-to-dev:
name: Publish as canary
needs: [ test-image-builds ]
runs-on: "ubuntu-latest"
if: ${{ github.ref == 'refs/heads/main' && !github.event.issue.pull_request }}
steps:
- name: "Create checkmates"
uses: "actions/checkout@v2"
- name: Generate metadata for Docker builds
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.namespace_dockerhub }}/${{ env.repository }}
quay.io/${{ env.namespace }}/${{ env.repository }}
ghcr.io/${{ env.namespace }}/${{ env.repository }}
tags: |
type=raw,value=develop
type=sha,format=long
flavor: |
latest=false
# Setup QEMU for multiarch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# and of course, we need to setup Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: "image=moby/buildkit:master,network=host"
# repeat this for other registries you want to use
# especially the official Docker Hub Registry
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
# change the username into yours if not using our bot, might use
# an env or secrets way in the future
username: RecapTimeBot
# you need to manually add our bot with write access if you use our PAT
password: ${{ secrets.GH_SERVICE_ACCOUNT_API_KEY }}
- name: Login to Red Hat Quay Container Registry
uses: docker/login-action@v1
with:
registry: quay.io
# change the username into yours if not using our bot
username: ${{ secrets.QUAYIO_USERNAME }}
# may not work on personal accounts if using our PAT
# we may try soon
password: ${{ secrets.QUAYIO_PASSWORD }}
- name: Build and push to GHCR + DockerHub and RHQC
id: image-build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
# arm64 can sometimes experience weird GnuTLS errors
platforms: linux/amd64