Repository navigation
78 lines (76 loc) · 2.61 KB
/
Copy pathdocker-publish.yml
File metadata and controls
78 lines (76 loc) · 2.61 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
name: Publish TypePHP Webman Builder
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Exact Docker image tag (vMAJOR.MINOR.PATCH, for example v0.0.10)'
required: true
type: string
push:
description: 'Push the exact version tag to Docker Hub'
required: true
default: true
type: boolean
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v4
- name: Resolve exact version tag
id: version
shell: bash
run: |
version="${{ github.event_name == 'push' && github.ref_name || inputs.version }}"
[[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]] || { echo "Invalid version tag: $version" >&2; exit 1; }
echo "tag=$version" >> "$GITHUB_OUTPUT"
echo "push=${{ github.event_name == 'push' || inputs.push }}" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v4
if: steps.version.outputs.push == 'true'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: docker/metadata-action@v6
id: meta
with:
images: tinywan/typephp-webman-builder
tags: |
type=ref,event=tag
type=raw,value=${{ inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
- uses: docker/build-push-action@v7
with:
context: ./docker
platforms: linux/amd64
push: ${{ steps.version.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true
- uses: docker/metadata-action@v6
id: meta-static
with:
images: tinywan/typephp-webman-builder-static
tags: |
type=ref,event=tag
type=raw,value=${{ inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
- uses: docker/build-push-action@v7
with:
context: ./docker
file: ./docker/Dockerfile.static
platforms: linux/amd64
push: ${{ steps.version.outputs.push }}
tags: ${{ steps.meta-static.outputs.tags }}
labels: ${{ steps.meta-static.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true