Skip to content

Commit

Permalink
Merge pull request #16 from Kerosene-Labs/update-workflow
Browse files Browse the repository at this point in the history
Update workflow
  • Loading branch information
hlafaille authored Dec 12, 2024
2 parents 709f66a + 72a487d commit 6e344c6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy
on:
release:
types:
- created
- published
push:
branches:
- main
Expand All @@ -15,63 +15,91 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
server-id: github
settings-path: ${{ github.workspace }}
- name: Install dependencies

- name: Install Node Dependencies
run: cd src/main/frontend && npm i

- name: Determine PROJECT_VERSION
id: set-project-version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "PROJECT_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "PROJECT_VERSION=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Show PROJECT_VERSION
run: echo "PROJECT_VERSION is $PROJECT_VERSION"

- name: Build with Maven
run: mvn -B package --file pom.xml
run: mvn -B package --file pom.xml -Dproject.version=${PROJECT_VERSION}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: app
path: |
target/billtracker-0.0.1.jar
target/billtracker-${{ env.PROJECT_VERSION }}.jar
publish_maven:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Install dependencies
run: cd src/main/frontend && npm i

- uses: actions/download-artifact@v4
with:
name: app

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s ./settings.xml -Dgithub.token=${{ secrets.ACCESS_TOKEN }}

publish_container:
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install dependencies
run: cd src/main/frontend && npm i

- uses: actions/download-artifact@v4
with:
name: app

- name: Build Container Image
run: docker build . -t ghcr.io/kerosene-labs/billtracker:${{ github.ref_name }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ACCESS_TOKEN }}

- name: Push Container Image
run: docker push ghcr.io/kerosene-labs/billtracker:${{ github.ref_name }}
9 changes: 5 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
</parent>
<groupId>com.kerosenelabs</groupId>
<artifactId>billtracker</artifactId>
<version>0.1.0</version>
<version>${project.version}</version>
<properties>
<project.version>0.0.0</project.version>
<java.version>21</java.version>
</properties>
<name>billtracker</name>
<description>A bill tracking web application.</description>
<distributionManagement>
Expand All @@ -34,9 +38,6 @@
<tag />
<url />
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
Expand Down

0 comments on commit 6e344c6

Please sign in to comment.