forked from winery/winery
-
Notifications
You must be signed in to change notification settings - Fork 10
154 lines (147 loc) · 4.94 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
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
name: Winery CI
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
pre_job:
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
docker_run_required: ${{ (github.repository_owner == 'OpenTOSCA' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags'))) }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
java17:
needs: pre_job
if: |
needs.pre_job.outputs.should_skip != 'true'
|| needs.pre_job.outputs.docker_run_required == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if AbstractResourceTest does not contain log().all().
run: |
if grep -i -q '\.all()' org.eclipse.winery.repository.rest/src/test/java/org/eclipse/winery/repository/rest/resources/AbstractResourceTest.java;
then
echo "Log output should be shortened. Use .ifValidationFails()!";
exit 1;
fi
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Publish package
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven
run: mvn -Pjava -B package
- name: Upload binary to artifacts
uses: actions/upload-artifact@v3
if: ${{ needs.pre_job.outputs.docker_run_required == 'true' }}
with:
name: artifacts
path: |
**/winery.war
**/winery-cli.jar
- name: Run codacy-coverage-reporter
if: ${{ github.repository_owner == 'OpenTOSCA' }}
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: org.eclipse.winery.reporting/target/site/jacoco-aggregate/jacoco.xml
frontend:
needs: pre_job
if: |
needs.pre_job.outputs.should_skip != 'true'
|| needs.pre_job.outputs.docker_run_required == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: Build with Maven
run: mvn -Pfrontend -B package
- name: Upload binary to artifacts
uses: actions/upload-artifact@v3
if: ${{ needs.pre_job.outputs.docker_run_required == 'true' }}
with:
name: artifacts
path: ${{ github.workspace }}/org.eclipse.winery.frontends/target/*.war
dockerBuild:
needs: [ java17, frontend ]
runs-on: ubuntu-latest
if: ${{ needs.pre_job.outputs.docker_run_required == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: artifacts
path: ${{ github.workspace }}
- name: Prepare artifacts
run: |
mv org.eclipse.winery.cli/target/winery-cli.jar winery-cli.jar
mv org.eclipse.winery.repository.rest/target/winery.war winery.war
ls -al
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: amd64,arm64,arm
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract metadata (tags, labels) for Docker
id: meta-cli
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-cli
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push latest Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.noBuild
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push latest CLI Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.cli
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-cli.outputs.tags }}
labels: ${{ steps.meta-cli.outputs.labels }}