Skip to content

Publish Docker image #59

Publish Docker image

Publish Docker image #59

Workflow file for this run

name: Publish Docker image
on:
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
- name: Safety Version
run: |
pip install packaging
package_version=$(cat safety/VERSION)
echo $package_version
echo "SAFETY_VERSION=$package_version" >> $GITHUB_ENV
- name: Extract Major and Minor Version
run: |
python scripts/extract_version.py
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/pyupio/safety
tags: |
type=raw,value=${{ env.SAFETY_VERSION }},suffix=-{{ sha }}
type=raw,value=${{ env.SAFETY_VERSION }}
type=raw,value=${{ env.SAFETY_MAJOR_VERSION }}.${{ env.SAFETY_MINOR_VERSION }}
type=raw,value=${{ env.SAFETY_MAJOR_VERSION }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=Safety CLI
org.opencontainers.image.description=Safety CLI is a Python dependency vulnerability scanner that enhances software supply chain security at every stage of development.
org.opencontainers.image.vendor=Safety Cybersecurity
org.opencontainers.image.licenses=MIT
- name: Build and Push image
uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: SAFETY_VERSION=${{ env.SAFETY_VERSION }}