-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (83 loc) · 2.64 KB
/
build_and_publish.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
name: Build and Publish
on:
pull_request:
push:
branches: [main, develop]
tags: ['*']
workflow_dispatch:
env:
REGISTRY: ghcr.io
BASE_IMG_REPO: ubuntu
BASE_IMG_TAG: 22.04
NARG: 2
jobs:
docker-build-and-publish:
name: Build and push the docker images
strategy:
fail-fast: false
matrix:
build: [Dev, Prod]
include:
- build: Dev
tag-suffix: '-dev'
build-type: Debug
- build: Prod
tag-suffix: ''
build-type: Release
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
submodules: recursive
# Need to avoid a shallow clone (fetch-depth=1) so that the lookup of the tag works
fetch-depth: 0
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
flavor: |
latest=auto
suffix=${{ matrix.tag-suffix }},onlatest=true
tags: |
type=semver,pattern={{raw}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Get previous tag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
id: tag_name
with:
fallback: beta
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: setup_buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
id: build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: ${{ github.event_name == 'push' && ( contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/develop' ) }}
build-args: |
base_image=${{ env.BASE_IMG_REPO }}
base_tag=${{ env.BASE_IMG_TAG }}
psyllid_tag=${{ steps.tag_name.outputs.tag }}
build_type=${{ matrix.build-type }}
narg=${{ env.NARG }}
tags: ${{ steps.docker_meta.outputs.tags }}
platforms: linux/amd64
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}