-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (39 loc) · 1.14 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: "docker build and push"
on:
pull_request:
paths:
- .github/workflows/docker.yml
- proto/**.proto
- src/**
- Cargo.toml
- Cargo.lock
- Dockerfile
- .dockerignore
push:
tags:
- '*'
env:
PUBLISH: ${{ github.ref_type == 'tags' }}
IMAGE: saint1991/gduck
TAG: ${{ github.ref_type == 'tags' && github.ref_name || github.sha }}
jobs:
docker_build:
runs-on: ubuntu-latest
steps:
- name: check publish
run: echo '${{ env.PUBLISH }}'
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
push: ${{ env.PUBLISH == 'true' }}
cache-from: ${{ format('type=registry,ref={0}:{1}', env.IMAGE, 'buildcache') }}
cache-to: ${{ format('type=registry,ref={0}:{1},mode=max', env.IMAGE, 'buildcache') }}
tags: |
${{ format('{0}:{1}', env.IMAGE, 'latest') }}
${{ format('{0}:{1}', env.IMAGE, env.TAG) }}