This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
forked from MORE-Platform/more-studymanager-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (107 loc) · 3.31 KB
/
test-build-push.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
name: Test, Build and Publish
on:
push:
workflow_dispatch:
inputs:
dockerTag:
description: If set, docker img is built and tagged accordingly
required: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/more-study-manager-frontend
jobs:
test:
name: "Run Tests"
runs-on: ubuntu-latest
steps:
- name: Checkout commit
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Cache NPM
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: 3rd-Party Licenses
run: |
mkdir -p target/
npm --silent run license:list > target/THIRD_PARTY.txt
cat target/THIRD_PARTY.txt
- name: Upload License List
if: always()
uses: actions/upload-artifact@v3
with:
name: 3rd Party Licenses
path: "target/THIRD_PARTY.txt"
- name: Check licenses
run: npm run license:check
# - name: Run tests
# run: npm run test:unit:once
#
# - name: Upload Test Results
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: Test Results
# path: "target/testResults.xml"
- name: Run build
run: npm run package
build-and-push-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: github.ref_name == 'main' || github.event.inputs.dockerTag != ''
needs:
- test
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{github.event.inputs.dockerTag || 'latest'}}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}