Skip to content

Commit 44b9f82

Browse files
build: update action.
1 parent d4decd0 commit 44b9f82

File tree

2 files changed

+80
-42
lines changed

2 files changed

+80
-42
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: build-and-push
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dockerImageTag:
7+
description: 'Docker Image Tag'
8+
required: true
9+
10+
jobs:
11+
build-and-push-to-ghcr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
- name: Prepare
17+
id: prepare
18+
run: |
19+
DOCKER_IMAGE=ghcr.io/kubeoperator/webkubectl
20+
DOCKER_PLATFORMS=linux/amd64,linux/arm64
21+
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
22+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest"
23+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
24+
echo ::set-output name=version::${TAG_NAME}
25+
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
26+
--build-arg VERSION=${TAG_NAME} \
27+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
28+
--build-arg --no-cache \
29+
--build-arg VCS_REF=${GITHUB_SHA::8} \
30+
${DOCKER_IMAGE_TAGS} .
31+
sed -i "2i\VERSION = ${TAG_NAME}" gotty/Makefile
32+
- name: Set up Docker Buildx
33+
uses: crazy-max/ghaction-docker-buildx@v3
34+
- name: Docker Buildx (build)
35+
run: |
36+
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
37+
- name: Login to GitHub Container Registry
38+
uses: docker/login-action@v2
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GH_TOKEN }}
43+
- name: Docker Buildx (push)
44+
run: |
45+
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
46+
47+
build-and-push-to-dockerhub:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v2
52+
- name: Prepare
53+
id: prepare
54+
run: |
55+
DOCKER_IMAGE=kubeoperator/webkubectl
56+
DOCKER_PLATFORMS=linux/amd64,linux/arm64
57+
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
58+
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest"
59+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
60+
echo ::set-output name=version::${TAG_NAME}
61+
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
62+
--build-arg VERSION=${TAG_NAME} \
63+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
64+
--build-arg --no-cache \
65+
--build-arg VCS_REF=${GITHUB_SHA::8} \
66+
${DOCKER_IMAGE_TAGS} .
67+
sed -i "2i\VERSION = ${TAG_NAME}" gotty/Makefile
68+
- name: Set up Docker Buildx
69+
uses: crazy-max/ghaction-docker-buildx@v3
70+
- name: Docker Buildx (build)
71+
run: |
72+
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
73+
- name: Login to DockerHub
74+
uses: docker/login-action@v2
75+
with:
76+
username: ${{ secrets.DOCKERHUB_USERNAME }}
77+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
78+
- name: Docker Buildx (push)
79+
run: |
80+
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}

.github/workflows/publish-to-ghcr.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)