Skip to content

feat: add container image scanning to ci and release #65

feat: add container image scanning to ci and release

feat: add container image scanning to ci and release #65

Workflow file for this run

name: Continuous Integration
# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
pull_request:
paths-ignore:
- 'README.md'
push:
branches:
- main
env:
LC_APPLICATION_ID: $(echo "${{ github.repository }}" | cut -d '/' -f2)
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
jobs:
# Ensure project builds before running testing matrix
build:
name: Build & Test
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Build
run: make all
- name: Run Tests
run: make test
container:
name: Container Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
# - name: Build Container and export to Docker
# uses: docker/build-push-action@v6
# with:
# context: .
# file: ./Dockerfile
# load: true
# platforms: linux/arm64
# tags: sonatypecommunity/the-cla:${{ github.ref_name }}
- name: Sonatype Lifecycle Evaluation
uses: sonatype-nexus-community/iq-github-action@db383e18b47e0afb291fde94345d8b70a85fcb5f
with:
serverUrl: ${{ secrets.SONATYPE_LIFECYCLE_URL }}
username: ${{ secrets.SONATYPE_LIFECYCLE_USERNAME }}
password: ${{ secrets.SONATYPE_LIFECYCLE_PASSWORD }}
applicationId: ${{ env.LC_APPLICATION_ID }}
stage: Release
targets: 'container:node:18-alpine3.18 /github/workspace'
# targets: 'container:docker.io/sonatypecommunity/the-cla:${{ github.ref_name }} ${{ github.workspace }}'
code_quality:
name: Code Quality
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Run Go Linter
uses: golangci/golangci-lint-action@v5
with:
version: latest
- name: Setup Sonatype CLI
uses: sonatype/actions/setup-iq-cli@v1
with:
iq-cli-version: latest
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Sonatype Lifecycle Evaluation
id: evaluate
uses: sonatype/actions/run-iq-cli@v1
with:
iq-server-url: ${{ secrets.SONATYPE_LIFECYCLE_URL }}
username: ${{ secrets.SONATYPE_LIFECYCLE_USERNAME }}
password: ${{ secrets.SONATYPE_LIFECYCLE_PASSWORD }}
application-id: ${{ env.LC_APPLICATION_ID }}
scan-targets: /
- name: Log evaluate action output
run: echo "${{ steps.evaluate.outputs.scan-id }} ${{ steps.evaluate.outputs.report-url }}"