study_xxqg/.github/workflows/push-to-docker.yml

91 lines
2.2 KiB
YAML
Raw Normal View History

2022-07-04 03:27:57 +00:00
name: docker build
on:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
branches:
- 'main'
2022-07-04 03:27:57 +00:00
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
2022-08-05 19:08:54 +00:00
with:
fetch-depth: 0
-
name: Fetch all tags
run: git fetch --force --tags
-
name: Set up Go
uses: actions/setup-go@v3
2022-07-04 03:27:57 +00:00
with:
go-version: 1.17
-
name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Set up QEMU
id: qemu
2022-07-04 03:27:57 +00:00
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
id: buildx
2022-07-04 03:27:57 +00:00
uses: docker/setup-buildx-action@v2
2022-08-05 18:02:32 +00:00
-
name: Check snapshot
if: "!startsWith(github.ref, 'refs/tags/')"
id: snapshot
run: echo '::set-output name=ARG::--snapshot'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
2022-08-07 12:41:53 +00:00
args: build --rm-dist --id docker ${{ steps.snapshot.outputs.ARG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: jolanse/study_xxqg
tags: |
type=raw,value=latest
type=ref,event=tag
-
name: Docker Login
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
2022-08-05 19:08:54 +00:00
tags: ${{ steps.meta.outputs.tags }}
2022-08-07 12:41:53 +00:00
cache-from: type=gha
cache-to: type=gha,mode=max
shm-size: 2g
2022-08-09 05:53:54 +00:00
ulimit: core=0:0