forked from eclipse-sw360/sw360
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (156 loc) · 6.08 KB
/
docker_deploy.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
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
172
173
174
175
176
177
# -----------------------------------------------------------------------------
# Copyright Helio Chissini de Castro 2022.
# Part of the SW360 Project.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# -----------------------------------------------------------------------------
name: Docker Build
on:
schedule:
- cron: '0 0 * * *' # Midnight
workflow_dispatch:
branches:
- main
push:
tags:
- 'sw360-*'
paths-ignore:
- "**.md"
env:
REGISTRY: ghcr.io
permissions: write-all
jobs:
docker_push:
if: ${{ github.event.schedule }} == '0 0 * * *' || ${{ github.event.act }}
name: Build Docker Image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout main repository
uses: actions/checkout@v3
- name: Set environment variables
run: |
cat .versions >> $GITHUB_ENV
echo "ORG_BASE_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "GIT_REVISION=$(git describe --abbrev=6 --always --tags --match=[0-9]*)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#------------------------------------------------
# Base
- name: Extract components metadata (tags, labels) for base image
id: meta_base
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base
- name: Identify base image
run: echo "Will be tagged as ${{ steps.meta_base.outputs.tags }} and labeled as ${{ steps.meta_base.outputs.labels }}"
- name: Build sw360 base container
uses: docker/build-push-action@v4
with:
context: .
target: base
push: true
load: false
build-args: |
LIFERAY_VERSION=${{ env.LIFERAY_VERSION }}
LIFERAY_SOURCE=${{ env.LIFERAY_SOURCE }}
tags: |
${{ steps.meta_base.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:${{ env.GIT_REVISION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:latest
labels: ${{ steps.meta_base.outputs.labels }}
cache-from: type=gha,scope=base
cache-to: type=gha,scope=base,mode=max
#------------------------------------------------
# Thrift
- name: Extract components metadata (tags, labels) for thrift image
id: meta_thrift
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift
- name: Identify thrift image
run: echo "Will be tagged as ${{ steps.meta_thrift.outputs.tags }} and labeled as ${{ steps.meta_thrift.outputs.labels }}"
- name: Build sw360 Thrift container
uses: docker/build-push-action@v4
with:
context: .
target: sw360thrift
push: true
load: false
build-args: |
THRIFT_VERSION=${{ env.THRIFT_VERSION }}
tags: |
${{ steps.meta_base.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:${{ env.THRIFT_VERSION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:latest
labels: ${{ steps.meta_thrift.outputs.labels }}
cache-from: type=gha,scope=thrift
cache-to: type=gha,scope=thrift,mode=max
#------------------------------------------------
# sw360 compilation
- name: Extract components metadata (tags, labels) for sw360
id: meta_sw360
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries
- name: Identify sw360 build image
run: echo "Will be tagged as ${{ steps.meta_sw360.outputs.tags }} and labeled as ${{ steps.meta_sw360.outputs.labels }}"
- name: Build sw360 build container
uses: docker/build-push-action@v4
with:
context: .
target: sw360
push: true
load: false
secret-files: |
"sw360=./scripts/docker-config/default_secrets"
tags: |
${{ steps.meta_sw360.outputs.tags }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:${{ env.GIT_REVISION }}
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:latest
labels: ${{ steps.meta_sw360.outputs.labels }}
build-contexts: |
sw360thrift=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/thrift:latest
cache-from: type=gha,scope=sw360
cache-to: type=gha,scope=sw360,mode=max
#------------------------------------------------
# sw360 runtime container
- name: Extract components metadata (tags, labels) runtime image
id: meta_runtime
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}
- name: Identify sw360 runtime image
run: echo "Will be tagged as ${{ steps.meta_runtime.outputs.tags }} and labeled as ${{ steps.meta_runtime.outputs.labels }}"
- name: Build sw360 build container
uses: docker/build-push-action@v4
with:
context: .
target: runtime
push: true
load: false
tags: |
${{ steps.meta_runtime.outputs.tags }}
labels: ${{ steps.meta_runtime.outputs.labels }}
build-contexts: |
base=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/base:latest
sw360=docker-image://${{ env.REGISTRY }}/${{ env.ORG_BASE_NAME }}/binaries:latest
cache-from: type=gha,scope=runtime
cache-to: type=gha,scope=runtime,mode=max