This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
Merge pull request #20 from Kerosene-Labs/update-workflow #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SDLC | |
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: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: 'java,javascript' # Specify your project's languages | |
# database: './codeql-db' # Optional: Customize the database location | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
with: | |
category: '/language-security-and-quality' # Customize category if needed | |
- 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 }} |