-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.53 KB
/
publish.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
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Publish Docker image
on:
push:
branches:
- master
tags:
- v*
jobs:
push_to_registries:
name: Push Docker image to Dockerhub
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: docker.io
DOCKER_IMAGE: mrjoshlab/udp2grpc
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKER_TARGET_PLATFORM: linux/amd64,linux/arm64,linux/arm/v7
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v2
with:
version: latest
- name: Prepare
if: success()
id: prepare
run: |
echo ::set-output name=docker_platform::${DOCKER_TARGET_PLATFORM}
echo ::set-output name=docker_image::${DOCKER_REGISTRY}/${DOCKER_IMAGE}
echo ::set-output name=release_version::${GITHUB_REF#refs/*/}
- name: Login to DockerHub
if: success()
run: |
echo "${DOCKER_TOKEN}" | docker login ${DOCKER_REGISTRY} --username "${DOCKER_USERNAME}" --password-stdin
- name: Run Buildx (push image)
if: success()
run: |
docker buildx build \
--platform ${{ steps.prepare.outputs.docker_platform }} \
--tag ${{ steps.prepare.outputs.docker_image }}:latest \
--tag ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.release_version }} \
--file ./Dockerfile \
--output type=image,push=true .