add acceptance-stage.yml π #8
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: Commit Stage | |
on: push | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: coverseed/catalog-service | |
VERSION: ${{ github.sha }} | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
security-events: write | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
cache: maven | |
- name: Build, unit tests and integration tests | |
run: | | |
mvn clean package | |
- name: Code vulnerability scanning | |
uses: anchore/scan-action@v3 | |
id: scan | |
with: | |
path: "${{ github.workspace }}" | |
fail-build: false | |
severity-cutoff: high | |
- name: Upload vulnerability report | |
uses: github/codeql-action/upload-sarif@v2 | |
if: success() || failure() | |
with: | |
sarif_file: ${{ steps.scan.outputs.sarif }} | |
- name: Validate Kubernetes manifests | |
uses: stefanprodan/kube-tools@v1 | |
with: | |
kubectl: 1.28.3 | |
kubeval: 0.16.1 | |
command: | | |
kubeval --strict -d k8s | |
package: | |
name: Package and Publish | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: [ build ] | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
security-events: write | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
cache: maven | |
- name: Build container image | |
run: | | |
mvn spring-boot:build-image \ | |
-Dspring-boot.build-image.imageName=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
- name: OCI image vulnerability scanning | |
uses: anchore/scan-action@v3 | |
id: scan | |
with: | |
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
fail-build: false | |
severity-cutoff: high | |
- name: Upload vulnerability report | |
uses: github/codeql-action/upload-sarif@v2 | |
if: success() || failure() | |
with: | |
sarif_file: ${{ steps.scan.outputs.sarif }} | |
- name: Log into container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish container image | |
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
- name: Publish container image (latest) | |
run: | | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |