Build and push Docker image #274
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 and push Docker image" | |
on: | |
push: | |
branches: ["*"] | |
tags: ["*"] | |
schedule: | |
- cron: "0 0 * * 0" | |
jobs: | |
main: | |
runs-on: "ubuntu-20.04" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v2" | |
- name: "Prepare build environment; build; push to Docker Hub, RedHat Quay" | |
run: | | |
IMAGE_TAG="$(echo '${{ github.ref }}' | sed -e 's,.*/\(.*\),\1,')" | |
[ "$IMAGE_TAG" == 'master' ] && IMAGE_TAG='latest' | |
[ "$IMAGE_TAG" == 'main' ] && IMAGE_TAG='latest' | |
docker buildx create --use | |
IMAGE_REGISTRY='docker.io' | |
echo '${{ secrets.DOCKER_HUB_PASSWORD }}' | docker login --username '${{ secrets.DOCKER_HUB_USERNAME }}' --password-stdin "$IMAGE_REGISTRY" | |
docker buildx build --push --platform 'linux/amd64' --tag "$IMAGE_REGISTRY/${{ github.repository }}:$IMAGE_TAG" --file Dockerfile . | |
IMAGE_REGISTRY='quay.io' | |
echo '${{ secrets.REDHAT_QUAY_PASSWORD }}' | docker login --username '${{ secrets.REDHAT_QUAY_USERNAME }}' --password-stdin "$IMAGE_REGISTRY" | |
docker buildx build --push --platform 'linux/amd64' --tag "$IMAGE_REGISTRY/${{ github.repository }}:$IMAGE_TAG" --file Dockerfile . |