Skip to content

Merge pull request #82 from CentreForDigitalHumanities/develop #27

Merge pull request #82 from CentreForDigitalHumanities/develop

Merge pull request #82 from CentreForDigitalHumanities/develop #27

Workflow file for this run

name: Build and Push Docker Images
on:
push:
branches:
- 'main'
- 'develop'
tags:
- '*'
pull_request:
branches:
- 'main'
- 'develop'
env:
AGENT_IMAGE_NAME: humitifier
AGENT_DOCKERFILE_PATH: ./agent/Dockerfile
AGENT_CONTEXT_PATH: ./agent
SERVER_IMAGE_NAME: humitifier-server
SERVER_DOCKERFILE_PATH: ./humitifier-server/Dockerfile
SERVER_CONTEXT_PATH: ./humitifier-server
jobs:
build-and-push-agent:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/centrefordigitalhumanities/humitifier/${{ env.AGENT_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
- name: Build and push main image
id: build
uses: docker/build-push-action@v6
with:
context: ${{ env.AGENT_CONTEXT_PATH }}
file: ${{ env.AGENT_DOCKERFILE_PATH }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-server:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/centrefordigitalhumanities/humitifier/${{ env.SERVER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
- name: Build and push main image
uses: docker/build-push-action@v6
with:
context: ${{ env.SERVER_CONTEXT_PATH }}
file: ${{ env.SERVER_DOCKERFILE_PATH }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
grype-scan-agent:
needs: build-and-push-agent
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/centrefordigitalhumanities/humitifier/${{ env.AGENT_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=pep440,pattern={{version}}
- name: Run the Anchore Grype scan action
uses: anchore/scan-action@v5
id: scan
with:
image: ghcr.io/centrefordigitalhumanities/humitifier/${{ env.AGENT_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
fail-build: false
severity-cutoff: critical
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v3
with:
category: 'agent'
sarif_file: ${{ steps.scan.outputs.sarif }}
grype-scan-server:
needs: build-and-push-server
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/centrefordigitalhumanities/humitifier/${{ env.SERVER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=pep440,pattern={{version}}
- name: Run the Anchore Grype scan action
uses: anchore/scan-action@v5
id: scan
with:
image: ghcr.io/centrefordigitalhumanities/humitifier/${{ env.SERVER_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
fail-build: false
severity-cutoff: critical
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v3
with:
category: 'server'
sarif_file: ${{ steps.scan.outputs.sarif }}
CodeQL:
name: "CodeQL: Analyze Python code"
runs-on: ubuntu-latest
permissions:
security-events: write
packages: read
actions: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: python
build-mode: none
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "CodeQL"