-
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (103 loc) · 3.5 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
---
on: # yamllint disable-line rule:truthy
push:
branches:
- 'master'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'
release:
types:
- 'created'
schedule:
# Every Tuesday at 03:10
- cron: '10 5 * * 2'
name: 🔍 Continuous integration
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os_name: ['alpine']
steps:
- name: 📦 Install goss
uses: e1himself/[email protected]
- name: 📦 Check out the codebase
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4
with:
fetch-depth: 0
- name: 🌎 Set environment variables
env:
IMAGE_NAMESPACE: wayofdev/build-deps
TEMPLATE: ${{ matrix.os_name }}
run: |
export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
&& { \
echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
echo "TEMPLATE=${TEMPLATE}"; \
echo "VERSION=${RELEASE_VERSION:1}"; \
} >> "$GITHUB_ENV"
- name: 🤖 Generate dist files
run: make generate
- name: 🐳 Define docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAMESPACE }}
tags: |
type=raw,event=branch,value=latest
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
prefix=${{ matrix.os_name }}-
- name: 🔑 Login to docker-hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
### For Cross Platform OSX builds uncomment these lines
- name: 🖥️ Set up QEMU
uses: docker/[email protected]
with:
platforms: arm64
- name: 🚀 Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
install: true
- name: 🏷️ Set tag for docker release image
if: success() && startsWith(github.ref, 'refs/tags/')
run: |
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-${{ env.VERSION }}" >> "$GITHUB_ENV"
- name: 🏷️ Set tag for docker master image
if: success() && ! startsWith(github.ref, 'refs/tags/')
run: |
echo "IMAGE_TAG=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest" >> "$GITHUB_ENV"
- name: 🛠️ Build and export to docker
uses: docker/build-push-action@v5
with:
context: ./dist/${{ env.TEMPLATE }}
load: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.IMAGE_NAMESPACE }}:${{ env.TEMPLATE }}-latest
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}
- name: 🧪 Test docker image
run: |
export IMAGE_TAG=${{ env.IMAGE_TAG }}; make test
- name: 📤 Push docker image
uses: docker/build-push-action@v5
with:
context: ./dist/${{ env.TEMPLATE }}
### For Cross Platform OSX builds uncomment these lines
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.IMAGE_TAG }}
cache-to: type=inline
...