Skip to content

Commit 684a5aa

Browse files
committed
fix(ci-cd): apply new pipeline, add dependabot.yml
1 parent 4171b43 commit 684a5aa

File tree

6 files changed

+129
-5
lines changed

6 files changed

+129
-5
lines changed

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
target-branch: "development"
6+
schedule:
7+
interval: "daily"
8+
assignees:
9+
- "vincejv"
10+
labels:
11+
- "dependencies"
12+
open-pull-requests-limit: 10
13+
14+
- package-ecosystem: "github-actions"
15+
# Workflow files stored in the
16+
# default location of `.github/workflows`
17+
directory: "/"
18+
target-branch: "development"
19+
schedule:
20+
interval: "daily"
21+
assignees:
22+
- "vincejv"
23+
labels:
24+
- "dependencies"
25+
- "ci-cd"
26+
open-pull-requests-limit: 10

.github/workflows/pr-reviewer.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PR Reviewer
2+
on:
3+
issue_comment:
4+
types: [ created, edited ]
5+
env:
6+
REPOSITORY_OWNER: vincejv
7+
REPOSITORY_BOT: fpibot
8+
jobs:
9+
review:
10+
name: Perform review
11+
if: ${{ github.event.issue.pull_request }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Approve pull request
15+
if: ${{ github.actor == env.REPOSITORY_OWNER && contains(github.event.comment.body, format('@{0}', env.REPOSITORY_BOT)) }}
16+
uses: hmarr/auto-approve-action@v3
17+
with:
18+
pull-request-number: ${{ github.event.issue.number }}
19+
github-token: ${{ secrets.FPI_BOT_TOKEN }}
20+
review-message: ${{ format('Hi @{0}, your code changes are approved! 🥳', github.event.issue.user.login) }}

.github/workflows/release-dev.yml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66

77
env:
88
SONAR_PROJECT_KEY: vincejv_dtone-dvs-api-java-client
9+
MVN_ARTIFACT_ID: dvs-apiclient
910

1011
jobs:
1112

1213
pre_job:
1314
name: Duplicate checks
1415
runs-on: ubuntu-latest
16+
if: ${{ !contains(github.event.head_commit.message, 'docs-update(') }} # skip for commits containing 'docs-update('
1517
outputs:
1618
should_skip: ${{ steps.skip_check.outputs.should_skip }}
1719
paths_result: ${{ steps.skip_check.outputs.paths_result }}
@@ -52,12 +54,14 @@ jobs:
5254
env:
5355
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
5456
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
55-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true
57+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} -Dsonar.qualitygate.wait=true -Pallow-snapshots
5658

5759
deploy:
58-
name: Release artifact
60+
name: Release artifact to central
5961
runs-on: ubuntu-latest
6062
needs: code_quality_checks
63+
outputs:
64+
artifact_version: ${{ steps.gen_ver.outputs.artifact_version }}
6165
permissions:
6266
contents: read
6367
packages: write
@@ -79,9 +83,53 @@ jobs:
7983
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
8084
gpg-passphrase: MAVEN_GPG_PASSPHRASE
8185

86+
- name: Prepare artifact version
87+
id: gen_ver
88+
run: |
89+
echo "artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
90+
8291
- name: Build and release to central repo
8392
env:
8493
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
8594
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
8695
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
87-
run: mvn -B deploy -Prelease-for-oss
96+
run: mvn -B deploy -Prelease-for-oss,allow-snapshots
97+
98+
pr_update:
99+
name: Pull request update
100+
if: always()
101+
needs: [ pre_job, deploy ]
102+
runs-on: ubuntu-latest
103+
permissions:
104+
contents: read
105+
pull-requests: write # allows job to decorate PRs with analysis results
106+
steps:
107+
- name: Update PR (Skip message)
108+
uses: marocchino/sticky-pull-request-comment@v2
109+
if: ${{ always() && needs.pre_job.outputs.should_skip == 'true' }}
110+
with:
111+
message: |
112+
⚪ Skipped CI/CD as deployment was done in a previous job
113+
114+
- name: Update PR (Success message)
115+
uses: marocchino/sticky-pull-request-comment@v2
116+
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version != '' }}
117+
with:
118+
message: |
119+
✅ Released version to SNAPSHOT repository: `${{ needs.deploy.outputs.artifact_version }}`
120+
121+
#### Add to your POM
122+
```xml
123+
<dependency>
124+
<groupId>com.vincejv</groupId>
125+
<artifactId>${{ env.MVN_ARTIFACT_ID }}</artifactId>
126+
<version>${{ needs.deploy.outputs.artifact_version }}</version>
127+
</dependency>
128+
```
129+
130+
- name: Update PR (Failure message)
131+
uses: marocchino/sticky-pull-request-comment@v2
132+
if: ${{ always() && needs.pre_job.outputs.should_skip != 'true' && needs.deploy.outputs.artifact_version == '' }}
133+
with:
134+
message: |
135+
❌ CI Build & Deployment failed, please check the [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details

.github/workflows/release-main.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
env:
99
SONAR_PROJECT_KEY: vincejv_dtone-dvs-api-java-client
10+
DEVELOPMENT_SYNC_BRANCH: development
1011

1112
jobs:
1213

@@ -43,6 +44,24 @@ jobs:
4344
with:
4445
github_token: ${{ secrets.GITHUB_TOKEN }}
4546

47+
rebase_dev:
48+
name: Sync development branch
49+
runs-on: ubuntu-latest
50+
needs: versioning
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v3
54+
with:
55+
ref: ${{ github.event.repository.default_branch }}
56+
fetch-depth: 0
57+
58+
- name: ReSync Branch
59+
uses: Joao208/[email protected]
60+
with:
61+
PERSONAL_TOKEN: ${{ secrets.FPI_BOT_TOKEN }}
62+
BRANCH_NAME: ${{ env.DEVELOPMENT_SYNC_BRANCH }}
63+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
64+
4665
code_quality_checks:
4766
name: Code quality checks
4867
runs-on: ubuntu-latest
@@ -86,7 +105,7 @@ jobs:
86105
body: ${{ needs.versioning.outputs.changelog }}
87106

88107
deploy:
89-
name: Release artifact
108+
name: Release artifact to central
90109
runs-on: ubuntu-latest
91110
needs: code_quality_checks
92111
permissions:

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<extension>
2121
<groupId>me.qoomon</groupId>
2222
<artifactId>maven-git-versioning-extension</artifactId>
23-
<version>9.3.1</version>
23+
<version>9.6.4</version>
2424
</extension>
2525

2626
</extensions>

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@
260260
</plugins>
261261
</build>
262262
</profile>
263+
<profile>
264+
<id>allow-snapshots</id>
265+
<repositories>
266+
<repository>
267+
<id>${maven.deploy.nexus.snapshot.repository-id}</id>
268+
<url>${maven.deploy.nexus.snapshot.repository-url}</url>
269+
<releases><enabled>false</enabled></releases>
270+
<snapshots><enabled>true</enabled></snapshots>
271+
</repository>
272+
</repositories>
273+
</profile>
263274
</profiles>
264275

265276
</project>

0 commit comments

Comments
 (0)