Skip to content

Commit 764f0c8

Browse files
committed
Add GitHub Actions CI/CD workflow
1 parent 9ee8bc1 commit 764f0c8

1 file changed

Lines changed: 146 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '[0-9]+.[0-9]+.x'
8+
pull_request:
9+
branches:
10+
- master
11+
- '[0-9]+.[0-9]+.x'
12+
schedule:
13+
- cron: '0 18 * * *'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
MAVEN_OPTS: '-Xmx4G -Xms1G -Djava.security.egd=file:/dev/./urandom'
21+
MAVEN_CLI_OPTS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
22+
23+
jobs:
24+
incremental-build:
25+
if: github.event_name == 'pull_request'
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 30
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Set up JDK 17
35+
uses: actions/setup-java@v4
36+
with:
37+
java-version: '17'
38+
distribution: 'temurin'
39+
cache: maven
40+
41+
- name: Configure Maven settings
42+
uses: s4u/maven-settings-action@v3.0.0
43+
with:
44+
servers: |
45+
[{
46+
"id": "github",
47+
"username": "${{ github.actor }}",
48+
"password": "${{ secrets.GITHUB_TOKEN }}"
49+
}]
50+
repositories: |
51+
[{
52+
"id": "github",
53+
"url": "https://maven.pkg.github.com/codice/*",
54+
"snapshots": {"enabled": true}
55+
}]
56+
57+
- name: Build
58+
run: mvn clean install $MAVEN_CLI_OPTS -DskipTests
59+
60+
full-build:
61+
if: github.event_name != 'pull_request'
62+
runs-on: ubuntu-latest
63+
timeout-minutes: 30
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
68+
- name: Set up JDK 17
69+
uses: actions/setup-java@v4
70+
with:
71+
java-version: '17'
72+
distribution: 'temurin'
73+
cache: maven
74+
75+
- name: Configure Maven settings
76+
uses: s4u/maven-settings-action@v3.0.0
77+
with:
78+
servers: |
79+
[{
80+
"id": "github",
81+
"username": "${{ github.actor }}",
82+
"password": "${{ secrets.GITHUB_TOKEN }}"
83+
}]
84+
repositories: |
85+
[{
86+
"id": "github",
87+
"url": "https://maven.pkg.github.com/codice/*",
88+
"snapshots": {"enabled": true}
89+
}]
90+
91+
- name: Build
92+
run: mvn clean install $MAVEN_CLI_OPTS -DskipTests
93+
94+
deploy:
95+
needs: full-build
96+
if: |
97+
github.event_name != 'pull_request' &&
98+
(github.ref == 'refs/heads/master' || contains(github.ref, '.x'))
99+
runs-on: ubuntu-latest
100+
environment: production
101+
permissions:
102+
packages: write
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v4
106+
107+
- name: Set up JDK 17
108+
uses: actions/setup-java@v4
109+
with:
110+
java-version: '17'
111+
distribution: 'temurin'
112+
cache: maven
113+
114+
- name: Configure Maven settings
115+
uses: s4u/maven-settings-action@v3.0.0
116+
with:
117+
servers: |
118+
[{
119+
"id": "releases",
120+
"username": "${{ github.actor }}",
121+
"password": "${{ secrets.GITHUB_TOKEN }}"
122+
},
123+
{
124+
"id": "snapshots",
125+
"username": "${{ github.actor }}",
126+
"password": "${{ secrets.GITHUB_TOKEN }}"
127+
},
128+
{
129+
"id": "github",
130+
"username": "${{ github.actor }}",
131+
"password": "${{ secrets.GITHUB_TOKEN }}"
132+
}]
133+
repositories: |
134+
[{
135+
"id": "github",
136+
"url": "https://maven.pkg.github.com/codice/*",
137+
"snapshots": {"enabled": true}
138+
}]
139+
140+
- name: Deploy
141+
run: |
142+
mvn deploy $MAVEN_CLI_OPTS \
143+
-DskipTests=true \
144+
-DretryFailedDeploymentCount=10 \
145+
-DaltReleaseDeploymentRepository=releases::https://maven.pkg.github.com/codice/acdebugger \
146+
-DaltSnapshotDeploymentRepository=snapshots::https://maven.pkg.github.com/codice/acdebugger

0 commit comments

Comments
 (0)