Skip to content

Merge pull request #16 from Kerosene-Labs/update-workflow #22

Merge pull request #16 from Kerosene-Labs/update-workflow

Merge pull request #16 from Kerosene-Labs/update-workflow #22

Workflow file for this run

name: Build and Deploy
on:
release:
types:
- published
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
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 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 -Dproject.version=${PROJECT_VERSION}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: app
path: |
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 }}