|
| 1 | +name: "Build and analyse" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - develop |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - develop |
| 11 | + |
| 12 | +jobs: |
| 13 | + # validate that the docker image is built. |
| 14 | + # will only scan for vulnerabilities and push to acr on push events |
| 15 | + docker-build: |
| 16 | + name: Build docker image |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + name: Checkout |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: SonarQube Scan |
| 25 | + uses: SonarSource/sonarqube-scan-action@v6 |
| 26 | + env: |
| 27 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 28 | + |
| 29 | + - name: Get project version from Cargo.toml |
| 30 | + id: get_version |
| 31 | + run: | |
| 32 | + version=$(grep '^version' oxybox/Cargo.toml | head -n 1 | cut -d '"' -f2) |
| 33 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 34 | +
|
| 35 | + - name: Docker build image |
| 36 | + shell: bash |
| 37 | + id: build |
| 38 | + env: |
| 39 | + DOCKERFILE: ./oxybox/Dockerfile |
| 40 | + TAG: ${{ steps.determine-tag.outputs.tag }} |
| 41 | + CONTEXT: ./oxybox |
| 42 | + VERSION: ${{ steps.get_version.outputs.version }} |
| 43 | + run: | |
| 44 | + docker buildx build \ |
| 45 | + --no-cache \ |
| 46 | + --label time=$(date +%Y%m%d%H%M%S) \ |
| 47 | + --label branch=${GITHUB_REF_NAME} \ |
| 48 | + --label commit=${{ github.sha }} \ |
| 49 | + --file ${DOCKERFILE} \ |
| 50 | + --build-arg "BRANCH=${{ github.ref_name }}" \ |
| 51 | + --build-arg "COMMIT=${{ github.sha }}" \ |
| 52 | + --tag baseflow/oxybox:latest \ |
| 53 | + --tag baseflow/oxybox:${VERSION} \ |
| 54 | + ${CONTEXT} |
| 55 | + |
| 56 | + - uses: aquasecurity/trivy-action@master |
| 57 | + name: Vulnerability Scan |
| 58 | + with: |
| 59 | + image-ref: baseflow/oxybox:latest |
| 60 | + scanners: vuln #,config,secret |
| 61 | + severity: 'CRITICAL,HIGH' |
| 62 | + vuln-type: 'os,library' |
| 63 | + ignore-unfixed: true |
| 64 | + exit-code: '1' |
| 65 | + format: 'table' |
0 commit comments