gns3-registry/.github/workflows/build-docker-images.yml

69 lines
2.3 KiB
YAML

name: Build Docker images and upload to DockerHub
on:
push:
branches:
- main
- master
schedule:
- cron: '37 7 * * 3'
workflow_dispatch:
inputs:
images:
description: 'List of images to be built'
required: false
type: string
jobs:
docker-images:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Check out repository code
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
# https://github.com/marketplace/actions/docker-setup-qemu
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
# https://github.com/marketplace/actions/docker-setup-buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
# https://github.com/marketplace/actions/docker-login
uses: docker/login-action@v2
with:
# GitHub Container Registry:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# DockerHub:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Install python requirements
run: python3 -m pip install --requirement .github/bin/requirements.txt
- name: Build and push images
env:
# DOCKER_USERNAME and DOCKER_PASSWORD are optional, they
# are only needed to authenticate into private repositories
#
# GitHub Container Registry:
# DOCKER_REPOSITORY: ghcr.io/${{ github.repository_owner }}
# DOCKER_USERNAME: ${{ github.repository_owner }}
# DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
#
# DockerHub:
DOCKER_REPOSITORY: ${{ secrets.DOCKERHUB_REPOSITORY }}
# DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
#
IMAGES: ${{ inputs.images }}
run: |
set -f
set -- $IMAGES
set +f
# use option --dir to use a subdirectory as a docker base dir
python3 "$GITHUB_WORKSPACE/.github/bin/docker_build" --dir "docker" "$@"