-
Notifications
You must be signed in to change notification settings - Fork 2
98 lines (84 loc) · 2.89 KB
/
build.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
name: build
on:
push:
branches:
- "main"
- "feature/*"
workflow_dispatch:
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout
uses: actions/checkout@v4
- name: Build for test
uses: docker/[email protected]
with:
files: ./docker-bake.hcl
load: true
set: |
"api.cache-from=type=gha,scope=api"
"web.cache-from=type=gha,scope=web"
"api.cache-to=type=gha,mode=max,scope=api"
"web.cache-to=type=gha,mode=max,scope=web"
"web.tags=espressoweb"
"api.tags=espressoapi"
- name: Start container
run: docker run -d -p 80:80 --health-interval=5s --name web espressoweb
- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: e2e
config: baseUrl=http://localhost
- name: Check container health
run: |
docker inspect -f '{{.State.Health.Status}}' web
[ "$(docker inspect -f '{{.State.Health.Status}}' web)" == "healthy" ]
- name: Docker log
if: always()
run: docker logs web
- name: Docker meta api
id: meta-api
uses: docker/metadata-action@v4
with:
images: ghcr.io/stefanschoof/espressoapi
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
bake-target: docker-metadata-action-api
- name: Docker meta web
id: meta-web
uses: docker/metadata-action@v4
with:
images: ghcr.io/stefanschoof/espressoweb
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
bake-target: docker-metadata-action-web
- name: Merge bake json into single file
# workaround for https://github.com/docker/buildx/issues/756
# and https://github.com/docker/metadata-action/issues/124
run: jq --slurp '.[0] * .[1]' ${{ steps.meta-web.outputs.bake-file }} ${{ steps.meta-api.outputs.bake-file }} > docker-bake.json
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Build
uses: docker/[email protected]
with:
push: ${{ github.event_name != 'pull_request' }}