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

96 lines
2.5 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.ref_name }}" == 'master' ]]; then
TAG="latest"
else
TAG="${{ github.ref_name }}"
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
-
2021-11-18 02:55:51 +08:00
name: Build x86 and export to Docker
2021-11-17 23:37:34 +08:00
uses: docker/build-push-action@v2
with:
context: .
load: true
2021-11-18 02:55:51 +08:00
platforms: linux/amd64
2021-11-17 23:54:43 +08:00
tags: ${{ env.TAG }}
build-args: version=${{ env.TAG }}
2021-11-17 23:37:34 +08:00
-
2021-11-18 02:55:51 +08:00
name: Test x86
run: |
2021-11-18 03:25:31 +08:00
docker run --rm ${{ env.TAG }}&
2021-11-18 03:22:59 +08:00
sleep 10
kill %1
2021-11-18 02:55:51 +08:00
-
name: Build arm64 and export to Docker
2021-11-18 02:55:51 +08:00
uses: docker/build-push-action@v2
with:
context: .
load: true
platforms: linux/arm64
tags: ${{ env.TAG }}
build-args: version=${{ env.TAG }}
2021-11-18 02:55:51 +08:00
-
name: Test arm64
run: |
docker run --rm ${{ env.TAG }}&
sleep 10
kill %1
-
name: Build armv7l and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
platforms: linux/arm/v7
tags: ${{ env.TAG }}
build-args: version=${{ env.TAG }}
-
name: Test armv7l
2021-11-17 23:37:34 +08:00
run: |
2021-11-18 03:25:31 +08:00
docker run --rm ${{ env.TAG }}&
2021-11-18 03:22:59 +08:00
sleep 10
kill %1
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, linux/arm/v7
push: true
tags: ${{ github.repository }}:${{ env.TAG }}, ${{ github.repository }}:latest
build-args: version=${{ env.TAG }}