Skip to content

Commit 919ad58

Browse files
committed
Add GitHub Actions workflow for Maven build and deployment to AWS CodeArtifact
1 parent acf64d0 commit 919ad58

File tree

2 files changed

+93
-11
lines changed

2 files changed

+93
-11
lines changed

.github/workflows/build.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Maven Build and Deploy to AWS CodeArtifact
2+
3+
on:
4+
push:
5+
branches:
6+
- 4.2.3.P1_Actions
7+
workflow_dispatch:
8+
9+
env:
10+
MVN_OPTS: "-P github --file ./pom.xml -DskipTests --batch-mode"
11+
12+
jobs:
13+
build:
14+
# runs-on: self-hosted
15+
runs-on: ubuntu-latest
16+
permissions:
17+
id-token: write
18+
contents: read
19+
steps:
20+
# Checkout the code
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0 # Fetch all history for tags and branches
25+
26+
# - name: Set up Maven
27+
# uses: stCarolas/setup-maven@v4
28+
# with:
29+
# maven-version: '3.9.6'
30+
31+
32+
# Configure AWS credentials
33+
- name: Configure AWS Credentials
34+
uses: aws-actions/configure-aws-credentials@v4
35+
with:
36+
role-to-assume: arn:aws:iam::851725588390:role/gh-deploy-protostream
37+
aws-region: "eu-west-1"
38+
39+
- name: Login to CodeArtifact
40+
id: codeartifact
41+
run: |
42+
token=$(aws codeartifact get-authorization-token --domain inpart --domain-owner 851725588390 --query authorizationToken --output text)
43+
url=$(aws codeartifact get-repository-endpoint --domain inpart --domain-owner 851725588390 --repository inpart-maven-releases --format maven --query repositoryEndpoint --output text)
44+
# Ensure URL ends with a trailing slash
45+
[[ "$url" != */ ]] && url="${url}/"
46+
echo "repo_token=$token" >> $GITHUB_OUTPUT
47+
echo "repo_url=$url" >> $GITHUB_OUTPUT
48+
echo "Using repository URL: $url"
49+
50+
- name: Set up JDK and Maven settings
51+
uses: actions/setup-java@v4
52+
with:
53+
java-version: '8'
54+
distribution: 'temurin'
55+
overwrite-settings: true
56+
cache: 'maven'
57+
server-id: inpart-maven-releases
58+
server-username: MAVEN_DEPLOY_USERNAME
59+
server-password: MAVEN_DEPLOY_PASSWORD
60+
61+
- name: Debug Maven Settings and Credentials
62+
run: |
63+
echo "Repository URL: ${{ steps.codeartifact.outputs.repo_url }}"
64+
echo "Token available: ${{ steps.codeartifact.outputs.repo_token != '' }}"
65+
mvn help:effective-settings
66+
67+
# - name: Set Release Version
68+
# run: |
69+
# # Get the latest tag by creation date
70+
# git fetch --tags
71+
# LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)
72+
# VERSION=${LATEST_TAG:1} # Remove the 'v' prefix
73+
# echo "Setting version to $VERSION"
74+
# mvn -DprocessAllModules -DnewVersion=$VERSION -DgenerateBackupPoms=false versions:set
75+
76+
- name: Build and Deploy
77+
env:
78+
MAVEN_DEPLOY_USERNAME: "aws"
79+
MAVEN_DEPLOY_PASSWORD: ${{ steps.codeartifact.outputs.repo_token }}
80+
run: |
81+
mvn $MVN_OPTS clean package deploy \
82+
-DaltDeploymentRepository=inpart-maven-releases::default::${{ steps.codeartifact.outputs.repo_url }}

parent/pom.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,17 +363,17 @@
363363
</plugins>
364364
</pluginManagement>
365365
<plugins>
366-
<plugin>
367-
<groupId>org.sonatype.plugins</groupId>
368-
<artifactId>nexus-staging-maven-plugin</artifactId>
369-
<extensions>true</extensions>
370-
<configuration>
371-
<!-- See configuration details at http://books.sonatype.com/nexus-book/reference/staging-deployment.html -->
372-
<nexusUrl>${jboss.releases.nexus.url}</nexusUrl>
373-
<serverId>${jboss.releases.repo.id}</serverId>
374-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
375-
</configuration>
376-
</plugin>
366+
<!-- <plugin>-->
367+
<!-- <groupId>org.sonatype.plugins</groupId>-->
368+
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>-->
369+
<!-- <extensions>true</extensions>-->
370+
<!-- <configuration>-->
371+
<!-- &lt;!&ndash; See configuration details at http://books.sonatype.com/nexus-book/reference/staging-deployment.html &ndash;&gt;-->
372+
<!-- <nexusUrl>${jboss.releases.nexus.url}</nexusUrl>-->
373+
<!-- <serverId>${jboss.releases.repo.id}</serverId>-->
374+
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
375+
<!-- </configuration>-->
376+
<!-- </plugin>-->
377377
<plugin>
378378
<groupId>org.apache.maven.plugins</groupId>
379379
<artifactId>maven-enforcer-plugin</artifactId>

0 commit comments

Comments
 (0)