Skip to content

cd

cd #271

Workflow file for this run

name: cd
on:
push:
branches: [main]
schedule:
- cron: "43 1 * * SUN" # every Sunday at 1:43 AM UTC
workflow_dispatch:
env:
IMAGE_NAME: network-tools
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lint Dockerfile
run: make lint
- name: Extract metadata for images
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# manually handle the 'latest' tag
flavor: |
latest=false
tags: |
type=raw,value=latest
labels: |
org.opencontainers.image.licenses=MIT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push images
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
prune:
needs: publish
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
contents: read
env:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --requirement .github/scripts/ghcr/prune/requirements.txt
- name: Prune all untagged images
run: python .github/scripts/ghcr/prune/prune.py --container ${{ env.IMAGE_NAME }} --prune-all-untagged --verbose