-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
flawmop
committed
Jan 3, 2024
1 parent
e47fa39
commit 88a192b
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Commit Stage | ||
on: push | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: flawmop/welcome-svc | ||
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@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
cache: gradle | ||
- name: Build, unit tests and integration tests | ||
run: | | ||
chmod +x gradlew | ||
./gradlew build | ||
- name: Code vulnerability scanning | ||
uses: anchore/scan-action@v3 | ||
id: scan | ||
with: | ||
path: "${{ github.workspace }}" | ||
fail-build: false | ||
severity-cutoff: high | ||
- name: Prepare Validate Kubernetes manifests | ||
uses: alexellis/arkade-get@master | ||
with: | ||
kubectl: v1.28.2 | ||
kubeval: v0.16.1 | ||
- name: Validate Kubernetes manifests | ||
# Different schema required because of https://github.com/instrumenta/kubeval/issues/301 | ||
run: | | ||
kustomize build k8s | kubeval --strict --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master - | ||
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@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
cache: gradle | ||
- name: Build container image | ||
run: | | ||
chmod +x gradlew | ||
./gradlew bootBuildImage \ | ||
--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: Log into container registry | ||
uses: docker/login-action@v2 | ||
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 |