-
-
Notifications
You must be signed in to change notification settings - Fork 16
171 lines (162 loc) · 5.67 KB
/
default.yaml
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Docker Build and Push
on:
schedule:
- cron: '0 10 * * 0' # Every Sunday at 10AM
push:
branches:
- master
- develop
- feature/*
tags:
- 'v*.*.*'
workflow_dispatch: # Allow manually triggering a build
defaults:
run:
shell: bash
jobs:
build-test-push:
name: Build, Test, Push
runs-on: ubuntu-20.04
env:
IMAGE: docksal/ci-agent
steps:
-
name: Install prerequisites for tests
run: |
set -xeuo pipefail
# Install bats for tests
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
bats -v
-
name: Checkout
uses: actions/checkout@v2
#-
# name: Set up QEMU
# uses: docker/setup-qemu-action@v1
# buildx has some glitches with local upstream (FROM) images. Disabled.
#-
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
-
name: Check Docker
run: |
docker version
docker info
-
name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
-
# Calculates docker image tags for the given build context
# The output is used in build and push step as `tags: ${{ steps.docker_meta.outputs.tags }}`
# See https://github.com/crazy-max/ghaction-docker-meta
name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
# List of Docker images to use as base name for tags
images: |
${{ env.IMAGE }}
ghcr.io/${{ env.IMAGE }}
tag-sha: true # add git short SHA as Docker tag
-
# Build for local use
name: Build image (base)
run: make build FLAVOR=base
-
# Build for local use
name: Build image (php)
run: make build FLAVOR=php
-
# Print image info
name: Docker image info
run: |
set -xeuo pipefail
docker image ls | grep "${{ env.IMAGE }}"
docker image inspect "${{ env.IMAGE }}:base-build"
docker image inspect "${{ env.IMAGE }}:php-build"
# Cache image layers in the registry
-
name: Push image cache (base)
uses: docker/build-push-action@v2
env:
IMAGE_CACHE: ghcr.io/${{ env.IMAGE }}:base-build
with:
context: base
file: base/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ${{ env.IMAGE_CACHE }} # Build cache tag in ghcr.io
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration
-
name: Push image cache (php)
uses: docker/build-push-action@v2
env:
IMAGE_CACHE: ghcr.io/${{ env.IMAGE }}:php-build
with:
context: php
file: php/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ${{ env.IMAGE_CACHE }} # Build cache tag in ghcr.io
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration
# Tests
-
name: Test image (base)
run: make test FLAVOR=base
-
name: Test image (php)
run: make test FLAVOR=php
-
# Generate image meta information
name: Docker image tags (base)
id: docker_tags_base
run: make tags FLAVOR=base
-
# Generate image meta information
name: Docker image tags (php)
id: docker_tags_php
run: make tags FLAVOR=php
-
# Push final image to the registry
# This will pick-up the build cache from the local build step
name: Push image (base)
# Don't run if the list of tags is empty
# Note: using tags from docker_tags (custom)
if: ${{ steps.docker_tags_base.outputs.tags != '' }}
uses: docker/build-push-action@v2
with:
context: base
file: base/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_tags_base.outputs.tags }} # Note: using tags from docker_tags (custom script)
labels: ${{ steps.docker_meta.outputs.labels }} # Note: using lables from docker_meta
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration
-
# Push final image to the registry
# This will pick-up the build cache from the local build step
name: Push image (php)
# Don't run if the list of tags is empty
# Note: using tags from docker_tags (custom)
if: ${{ steps.docker_tags_php.outputs.tags != '' }}
uses: docker/build-push-action@v2
with:
context: php
file: php/Dockerfile
#platforms: linux/amd64,linux/arm64
tags: ${{ steps.docker_tags_php.outputs.tags }} # Note: using tags from docker_tags (custom script)
labels: ${{ steps.docker_meta.outputs.labels }} # Note: using lables from docker_meta
push: ${{ github.event_name != 'pull_request' }} # Don't push for PRs
cache-to: type=inline # Write the cache metadata into the image configuration