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

78 lines
1.9 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
-
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 }}
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 arm and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
platforms: linux/arm64
tags: ${{ env.TAG }}
-
name: Test arm
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
push: true
2021-11-18 04:30:30 +08:00
tags: ${{ github.repository }}:${{ env.TAG }}