Skip to content

Merge pull request #1 from naveedious/docs/Readme #30

Merge pull request #1 from naveedious/docs/Readme

Merge pull request #1 from naveedious/docs/Readme #30

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches: [ "main" ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get build tag
id: date
run: echo "tag=$(date +'%Y%m%d').${{ github.run_number }}" >> $GITHUB_OUTPUT
# Build is skipped if Trivy exits with code 1
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/episodeguard:latest
ghcr.io/${{ github.repository_owner }}/episodeguard:${{ steps.date.outputs.tag }}
build-args: |
BUILD_DATE=${{ steps.date.outputs.tag }}
VERSION=${{ steps.date.outputs.tag }}
REVISION=${{ github.sha }}
- name: Run Trivy image scan
uses: aquasecurity/trivy-action@v0.35.0
with:
scan-type: 'image'
image-ref: 'ghcr.io/${{ github.repository_owner }}/episodeguard:${{ steps.date.outputs.tag }}'
format: 'table'
severity: 'HIGH,CRITICAL'
exit-code: '1' # Fails the pipeline if findings match severity criteria
ignore-unfixed: true # Excludes flaws with no vendor patch yet
trivyignores: './.trivyignore'
- name: Delete old package versions (keep last 3)
uses: actions/delete-package-versions@v5
with:
package-name: episodeguard
package-type: container
min-versions-to-keep: 3
ignore-versions: latest