build-and-push #2
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
dockerImageTag: | |
description: 'Docker Image Tag' | |
required: true | |
jobs: | |
build-and-push-to-ghcr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=ghcr.io/kubeoperator/webkubectl | |
DOCKER_PLATFORMS=linux/amd64,linux/arm64 | |
TAG_NAME=${{ github.event.inputs.dockerImageTag }} | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" | |
echo ::set-output name=docker_image::${DOCKER_IMAGE} | |
echo ::set-output name=version::${TAG_NAME} | |
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ | |
--build-arg VERSION=${TAG_NAME} \ | |
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | |
--build-arg --no-cache \ | |
--build-arg VCS_REF=${GITHUB_SHA::8} \ | |
${DOCKER_IMAGE_TAGS} . | |
sed -i "2i\VERSION = ${TAG_NAME}" gotty/Makefile | |
- name: Set up Docker Buildx | |
uses: crazy-max/ghaction-docker-buildx@v3 | |
- name: Docker Buildx (build) | |
run: | | |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Docker Buildx (push) | |
run: | | |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} | |
build-and-push-to-dockerhub: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=kubeoperator/webkubectl | |
DOCKER_PLATFORMS=linux/amd64,linux/arm64 | |
TAG_NAME=${{ github.event.inputs.dockerImageTag }} | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" | |
echo ::set-output name=docker_image::${DOCKER_IMAGE} | |
echo ::set-output name=version::${TAG_NAME} | |
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ | |
--build-arg VERSION=${TAG_NAME} \ | |
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | |
--build-arg --no-cache \ | |
--build-arg VCS_REF=${GITHUB_SHA::8} \ | |
${DOCKER_IMAGE_TAGS} . | |
sed -i "2i\VERSION = ${TAG_NAME}" gotty/Makefile | |
- name: Set up Docker Buildx | |
uses: crazy-max/ghaction-docker-buildx@v3 | |
- name: Docker Buildx (build) | |
run: | | |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Buildx (push) | |
run: | | |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} |