I have a project like that (https://github.com/senolatac/hexagonal-architecture-demo/tree/core-dependency) I try to create a simple github-action test step with github action.
On my project, there is a dependency like:
<dependency>
<groupId>com.sha</groupId>
<artifactId>sha-core</artifactId>
<version>0.0.1</version>
</dependency>
And the github link is here: https://github.com/senolatac/sha-core
Here, I try to build main project with github action like that:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.ACCESS_TOKEN }}
#ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
repository: senolatac/sha-core
- name: Build project with Maven
run: mvn -B package --file pom.xml
- uses: actions/checkout@v4
- name: Build project with Maven
run: mvn -B package --file pom.xml
So it is like, build sub project then build main project but it gives error: Could not find artifact com.sha:sha-core:jar:0.0.1 in central
Is there a way to handle it with github action?
Solved like that:
name: Main
on: [push]
jobs:
build_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: actions/checkout@v4
with:
ref: main
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
repository: senolatac/sha-core
- name: Install core project with Maven
run: |
mvn -B install --file pom.xml
- uses: actions/checkout@v4
- name: Build project with Maven
run: |
mvn compile
mvn -B package --file pom.xml