Build Container #111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Container | |
on: | |
push: | |
branches: [ main ] | |
tags: ["v*"] | |
paths: | |
- .github/workflows/build-container.yml | |
- .docker/build.Dockerfile | |
pull_request: | |
branches: [ main ] | |
paths: | |
- .github/workflows/build-container.yml | |
- .docker/build.Dockerfile | |
workflow_dispatch: | |
repository_dispatch: | |
schedule: | |
# rebuild image every sunday | |
- cron: "0 0 * * 0" | |
jobs: | |
build: | |
name: Upload images for building openvas-smb | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup container meta information | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ github.repository }}-build | |
labels: | | |
org.opencontainers.image.vendor=Greenbone | |
org.opencontainers.image.base.name=debian:stable-slim | |
flavor: latest=false # no latest container tag for git tags | |
tags: | | |
# create container tag for git tags | |
type=ref,event=tag | |
type=ref,event=pr | |
# use latest for main branch | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- run: echo "Build and push ${{ steps.meta.outputs.tags }}" | |
- 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 | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
file: .docker/build.Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |