Bugfix #13
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: Chainguard Image Build | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn clean package -DskipTests | |
- name: Upload JAR as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: heartflame-fleet | |
path: target/fleet-1.0-SNAPSHOT.jar | |
docker: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download JAR artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: heartflame-fleet | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build Docker image | |
run: docker build -t heartflame-fleet:${{ github.sha }} . | |
- name: Tag Docker image as latest | |
if: github.ref == 'refs/heads/main' | |
run: docker tag heartflame-fleet:${{ github.sha }} ghcr.io/heartflamesoftware/heartflame-fleet:latest | |
- name: Scan Docker image with Trivy | |
uses: aquasecurity/trivy-action@0.20.0 | |
with: | |
image-ref: 'heartflame-fleet:${{ github.sha }}' | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
exit-code: '0' | |
- name: Upload Trivy SARIF Report | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: 'trivy-results.sarif' | |
- name: Push Docker image to GHCR | |
if: success() | |
run: | | |
docker push ghcr.io/heartflamesoftware/heartflame-fleet:${{ github.sha }} | |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
docker push ghcr.io/heartflamesoftware/heartflame-fleet:latest | |
fi |