main
yml 72 lines 2.28 KB
Raw
1 name: docker-image
2
3 on:
4 workflow_dispatch:
5 inputs:
6 version:
7 description: 'Release tag (e.g., v3.0.2)'
8 required: true
9 type: string
10 push:
11 tags:
12 - 'v*'
13
14 permissions:
15 contents: read
16 packages: write
17
18 jobs:
19 build:
20 runs-on: ubuntu-latest
21 steps:
22 - name: Checkout
23 uses: actions/checkout@v5
24
25 - name: Set up QEMU
26 uses: docker/setup-qemu-action@v4
27
28 - name: Set up Docker Buildx
29 uses: docker/setup-buildx-action@v4
30
31 - name: Log in to GHCR
32 uses: docker/login-action@v4
33 with:
34 registry: ghcr.io
35 username: ${{ github.actor }}
36 password: ${{ secrets.GITHUB_TOKEN }}
37
38 - name: Log in to Docker Hub
39 uses: docker/login-action@v4
40 with:
41 username: rejetto
42 password: ${{ secrets.DOCKERHUB_TOKEN }}
43
44 - name: Docker metadata
45 id: meta
46 uses: docker/metadata-action@v6
47 with:
48 # disable the action's automatic latest tag so prereleases cannot overwrite latest
49 flavor: |
50 latest=false
51 images: |
52 ghcr.io/${{ github.repository }}
53 docker.io/rejetto/hfs
54 tags: |
55 type=ref,event=tag
56 # workflow_dispatch does not expose a tag ref, so channel tags must be derived from inputs.version
57 type=raw,value=${{ inputs.version }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.version != '' }}
58 type=raw,value=latest,enable=${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) || (github.event_name == 'workflow_dispatch' && inputs.version != '' && !contains(inputs.version, '-')) }}
59 type=raw,value=beta,enable=${{ (github.ref_type == 'tag' && contains(github.ref_name, '-')) || (github.event_name == 'workflow_dispatch' && inputs.version != '' && contains(inputs.version, '-')) }}
60 type=sha
61
62 - name: Build and push
63 uses: docker/build-push-action@v7
64 with:
65 context: .
66 file: ./Dockerfile
67 platforms: linux/amd64,linux/arm64
68 push: true
69 build-args: |
70 HFS_VERSION=${{ inputs.version || github.ref_name }}
71 tags: ${{ steps.meta.outputs.tags }}
72 labels: ${{ steps.meta.outputs.labels }}