-
Notifications
You must be signed in to change notification settings - Fork 12
33 lines (25 loc) · 1.2 KB
/
docker-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 .