netmaker/.github/workflows/publish-docker.yml

62 lines
1.6 KiB
YAML
Raw Normal View History

name: Publish Docker
2021-04-09 06:05:07 +08:00
on:
workflow_dispatch:
inputs:
tag:
description: 'docker tag'
required: true
release:
types: [published]
jobs:
docker:
runs-on: ubuntu-latest
steps:
2021-11-17 23:37:34 +08:00
-
name: Set tag
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
TAG=${{ github.event.inputs.tag }}
elif [[ "${{ github.base_ref }}" == 'master' ]]; then
TAG="latest"
else
TAG="${{ github.base_ref }}"
fi
echo "TAG=${TAG}" >> $GITHUB_ENV
2021-11-17 23:37:34 +08:00
-
name: Checkout
uses: actions/checkout@v2
2021-11-17 23:37:34 +08:00
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
2021-11-17 23:37:34 +08:00
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
2021-11-17 23:37:34 +08:00
-
name: Login to DockerHub
2021-04-09 06:05:07 +08:00
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2021-11-17 23:37:34 +08:00
-
name: Build and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
2021-11-18 02:49:34 +08:00
platforms: linux/amd64,linux/arm64
2021-11-17 23:54:43 +08:00
tags: ${{ env.TAG }}
2021-11-17 23:37:34 +08:00
-
name: Test
run: |
2021-11-18 02:49:34 +08:00
docker run --rm --entrypoint apk add file; file netmaker ${{ env.TAG }}
2021-11-17 23:37:34 +08:00
-
name: Build and push
2021-04-09 06:05:07 +08:00
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ github.respository }}:${{ env.TAG }}