-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (130 loc) · 4.94 KB
/
continuous-integration.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: Continuous Integration Build Artifacts
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
fetch-depth: 0 # checkout full GIT history for auto-changelog
- name: Get GIT tags for auto-changelog generation (startingVersion config option)
run: git fetch --tags origin
- name: Set environment variable "commit-message"
run: echo "commit-message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
- name: Display environment variable "commit-message"
run: echo "commit-message=${{ env.commit-message }}"
- name: Set environment variable "commit-author"
run: echo "commit-author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_ENV
- name: Display environment variable "commit-author"
run: echo "commit-author=${{ env.commit-author }}"
- name: Set environment variable "is-auto-commit"
if: env.commit-message == env.CI_COMMIT_MESSAGE && env.commit-author == env.CI_COMMIT_AUTHOR
run: echo "is-auto-commit=true" >> $GITHUB_ENV
- name: Display environment variable "is-auto-commit"
run: echo "is-auto-commit=${{ env.is-auto-commit }}"
- name: Info message on CI auto commit
if: env.is-auto-commit
run: echo "Continuous Integration Auto Commit - The following steps will be skipped"
- uses: actions/setup-node@v4
if: env.is-auto-commit == false
with:
node-version: '20'
- name: (Main) Install nodes packages
if: env.is-auto-commit == false
run: npm ci
- name: (Main) Build package (lint, test, build, package, merge)
if: env.is-auto-commit == false
run: npm run package
- name: (Main) Archive test code coverage results
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: test-code-coverage-report
path: coverage
retention-days: 31
if-no-files-found: error
- name: (Main) Archive documentation
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs
retention-days: 31
if-no-files-found: error
- name: (Main) Archive CHANGELOG.md
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md
retention-days: 31
if-no-files-found: error
- name: (Main) Archive build artifacts distribution-production
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: distribution-production
path: dist
retention-days: 31
if-no-files-found: error
- name: (Main) Archive build artifacts distribution-development
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: distribution-development
path: devdist
retention-days: 31
if-no-files-found: error
- name: (Example) Install nodes packages
if: env.is-auto-commit == false
working-directory: example
run: npm ci
- name: (Example) Build package (lint, test, build, package, merge)
if: env.is-auto-commit == false
working-directory: example
run: npm run package
- name: (Example) Archive test code coverage results
if: env.is-auto-commit == false
uses: actions/upload-artifact@v4
with:
name: example-test-code-coverage-report
path: example/coverage
retention-days: 31
- name: (Example Servlet) Set up JDK 17
if: env.is-auto-commit == false
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17
cache: 'maven'
- name: (Example Servlet) Build with Maven
if: env.is-auto-commit == false
working-directory: example/search-example-servlet
run: mvn -B package --file pom.xml
- name: Display event name
run: echo "github.event_name=${{ github.event_name }}"
- name: Commit build artifacts (dist, devdist, docs, coverage)
# Don't run again on already pushed auto commit. Don't run on pull request events.
# Git pull before add/commit/push to reduce race conditions on parallel builds
if: env.is-auto-commit == false && github.event_name != 'pull_request'
run: |
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
git config --global user.email "[email protected]"
git fetch origin
git status
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
git status
git rebase --strategy-option=theirs origin/master --verbose
git status
git push --verbose