-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (116 loc) · 4.62 KB
/
ci_test-release.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: npm CI for test and release actions
on:
push:
branches:
- 'main'
- 'feature/**'
- 'fix/**'
pull_request:
branches:
- 'main'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v2
with:
fetch-depth: 0 # shallow clones should be disabled for a better relevancy of analysis
- name: Update Node.js to latest stable version
run: |
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
- name: Install dependencies
run: npm ci
- name: Test project
run: |
npm run test-pre-it
npm test
npm run test-post-it
- name: Perform static code analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
cp ./.github/workflows/sonar-project.properties ./
npm run scan
consistency-check:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Update Node.js to latest stable version
run: |
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
- name: Install dependencies
run: npm install
- name: Compare the expected and actual package-lock.json files
run: |
if [[ "$(git diff ./package-lock.json | wc -l)" -gt "0" ]]; then
echo "The package-lock.json file is not up to date." >&2
exit 1
fi
release:
needs: [ test, consistency-check ]
if: github.event_name == 'push' && github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Update Node.js to latest stable version
run: |
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
- name: Install dependencies
run: npm ci
- name: Perform tagging if version has changed
id: tagging
uses: brettaufheber/auto-tagging-action@v1
with:
command: jq -r '.version' package.json
snapshot-pattern: ^0\. # major part is 0
tag-prefix: v
- name: Build project
run: npm run build
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub container registry (base image RHEL UBI)
if: ${{ steps.tagging.outputs.tag-created == 'yes' && steps.tagging.outputs.version-major-minor-patch }}
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./Dockerfile-rhel
tags: |
ghcr.io/${{ github.repository_owner }}/central-saml-logout:rhel
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major }}-rhel
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor }}-rhel
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor-patch }}-rhel
- name: Publish to GitHub container registry (base image Ubuntu)
if: ${{ steps.tagging.outputs.tag-created == 'yes' && steps.tagging.outputs.version-major-minor-patch }}
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./Dockerfile
tags: |
ghcr.io/${{ github.repository_owner }}/central-saml-logout:ubuntu
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major }}-ubuntu
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor }}-ubuntu
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor-patch }}-ubuntu
ghcr.io/${{ github.repository_owner }}/central-saml-logout:latest
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major }}
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor }}
ghcr.io/${{ github.repository_owner }}/central-saml-logout:${{ steps.tagging.outputs.version-major-minor-patch }}