chore(CI):support docker build in GitHub Actions

https://github.com/appleboy/gorush/issues/704

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu 2022-12-24 12:41:17 +08:00
parent 7101fbd9c8
commit 6b6ef695db
1 changed files with 109 additions and 0 deletions

View File

@ -4,6 +4,8 @@ on:
push:
branches:
- master
tags:
- 'v*'
jobs:
build:
@ -27,3 +29,110 @@ jobs:
- name: Check binary
run : |
./release/linux/amd64/gorush --help
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta for linux amd64
id: meta-linux-amd64
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
suffix=linux-amd64
images: |
appleboy/gorush
ghcr.io/appleboy/gorush
tags: |
type=raw,value=
type=raw,value=latest,suffix=,enable={{is_default_branch}}
type=semver,event=tag,pattern={{version}},suffix=-linux-amd64
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-amd64
type=semver,event=tag,pattern={{major}},suffix=-linux-amd64
-
name: Build and push linux amd64
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.linux.amd64
platforms: linux/amd64
push: true
tags: ${{ steps.meta-linux-amd64.outputs.tags }}
labels: ${{ steps.meta-linux-amd64.outputs.labels }}
-
name: Docker meta for linux arm64
id: meta-linux-arm64
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
suffix=linux-arm64
images: |
appleboy/gorush
ghcr.io/appleboy/gorush
tags: |
type=raw,value=
type=semver,event=tag,pattern={{version}},suffix=-linux-arm64
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm64
type=semver,event=tag,pattern={{major}},suffix=-linux-arm64
-
name: Build and push linux arm64
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.linux.arm64
platforms: linux/arm64
push: true
tags: ${{ steps.meta-linux-arm64.outputs.tags }}
labels: ${{ steps.meta-linux-arm64.outputs.labels }}
-
name: Docker meta for linux arm
id: meta-linux-arm
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
suffix=linux-arm
images: |
appleboy/gorush
ghcr.io/appleboy/gorush
tags: |
type=raw,value=
type=semver,event=tag,pattern={{version}},suffix=-linux-arm
type=semver,event=tag,pattern={{major}}.{{minor}},suffix=-linux-arm
type=semver,event=tag,pattern={{major}},suffix=-linux-arm
-
name: Build and push linux arm
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.linux.arm
platforms: linux/arm
push: true
tags: ${{ steps.meta-linux-arm.outputs.tags }}
labels: ${{ steps.meta-linux-arm.outputs.labels }}