-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-semver-simple.yml
66 lines (64 loc) · 2.14 KB
/
docker-semver-simple.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Build PHP FPM Container and Upload to Dockerhub
on:
workflow_call:
secrets:
DockerHubUser:
required: true
DockerHubPass:
required: true
DockerHubPrefix:
required: true
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DockerHubUser }}
password: ${{ secrets.DockerHubPass }}
######################################################
# Setting up final build tags
######################################################
- name: Prepare Tags
id: prep
run: |
IMAGE=${{ secrets.DockerHubPrefix }}/${GITHUB_REPOSITORY#*/}
echo ::set-output name=image::${IMAGE}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ steps.prep.outputs.image }}
flavor: |
latest=auto
tags: |
type=edge,enable=true,branch=main
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
######################################################
# Setup Cache and BuildX
######################################################
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
driver-opts: network=host
######################################################
# Build!
######################################################
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
cache-from: "type=gha"
cache-to: "type=gha,mode=max"
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}