|
1 | | -name: Build Docker image task |
2 | | - |
3 | | -# Builds the multi-arch image (linux/amd64,arm64) and, on a main publish, pushes it plus the Docker Hub overview. |
4 | | -# Branch drives config and tags: main => Release/`latest`, else Debug/`develop`, plus the `:SemVer2` tag. Smoke builds |
5 | | -# amd64 only and never pushes; registry buildcache is branch-scoped. The orchestrator passes `branch` explicitly |
6 | | -# (the publisher builds one branch per run - the trigger ref - and smoke passes github.ref_name). |
7 | | -on: |
8 | | - workflow_call: |
9 | | - inputs: |
10 | | - # Push the built image and the Docker Hub overview. |
11 | | - push: |
12 | | - required: false |
13 | | - type: boolean |
14 | | - default: false |
15 | | - # Git ref to check out / version (empty = default checkout ref). |
16 | | - ref: |
17 | | - required: false |
18 | | - type: string |
19 | | - default: '' |
20 | | - # Logical branch: main => Release/`latest`, else Debug/`develop`. Required (see header). |
21 | | - branch: |
22 | | - required: true |
23 | | - type: string |
24 | | - # Smoke: build linux/amd64 only, never push, skip the shared cache-to. Fast PR feedback. |
25 | | - smoke: |
26 | | - required: false |
27 | | - type: boolean |
28 | | - default: false |
29 | | - # Version from the orchestrator's single NBGV run (threaded). This task does not |
30 | | - # re-run NBGV on the detached commit, which could classify the branch differently. |
31 | | - semver2: |
32 | | - required: true |
33 | | - type: string |
34 | | - assembly_version: |
35 | | - required: true |
36 | | - type: string |
37 | | - assembly_file_version: |
38 | | - required: true |
39 | | - type: string |
40 | | - assembly_informational_version: |
41 | | - required: true |
42 | | - type: string |
43 | | - |
44 | | -jobs: |
45 | | - |
46 | | - build-docker: |
47 | | - name: Build Docker image job |
48 | | - runs-on: ubuntu-latest |
49 | | - |
50 | | - steps: |
51 | | - |
52 | | - - name: Checkout step |
53 | | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
54 | | - with: |
55 | | - ref: ${{ inputs.ref }} |
56 | | - |
57 | | - # QEMU only emulates arm64; smoke is amd64-only, so skip it to save setup cost. |
58 | | - - name: Setup QEMU step |
59 | | - if: ${{ !inputs.smoke }} |
60 | | - uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 |
61 | | - with: |
62 | | - platforms: linux/amd64,linux/arm64 |
63 | | - |
64 | | - - name: Setup Buildx step |
65 | | - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 |
66 | | - with: |
67 | | - platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }} |
68 | | - |
69 | | - # Always login (even on smoke) for higher pull/cache-read rate limits; the credentials are in both the |
70 | | - # Actions and Dependabot secret stores so a Dependabot push CI run can log in too. Forks cannot push here. |
71 | | - - name: Login to Docker Hub step |
72 | | - uses: docker/login-action@c99871dec2022cc055c062a10cc1a1310835ceb4 # v4.3.0 |
73 | | - with: |
74 | | - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
75 | | - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
76 | | - |
77 | | - - name: Docker build and push step |
78 | | - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 |
79 | | - with: |
80 | | - context: . |
81 | | - push: ${{ inputs.push }} |
82 | | - file: ./Docker/Dockerfile |
83 | | - tags: | |
84 | | - docker.io/ptr727/plexcleaner:${{ inputs.branch == 'main' && 'latest' || 'develop' }} |
85 | | - docker.io/ptr727/plexcleaner:${{ inputs.semver2 }} |
86 | | - platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }} |
87 | | - # Read both branches' caches (near-identical layers), write only this branch's tag and only when pushing. |
88 | | - # mode=max caches the builder publish; ignore-error keeps a cache hiccup from failing a publish. |
89 | | - cache-from: | |
90 | | - type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-main |
91 | | - type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-develop |
92 | | - cache-to: ${{ inputs.push && format('type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-{0},mode=max,ignore-error=true', inputs.branch) || '' }} |
93 | | - build-args: | |
94 | | - LABEL_VERSION=${{ inputs.semver2 }} |
95 | | - BUILD_CONFIGURATION=${{ inputs.branch == 'main' && 'Release' || 'Debug' }} |
96 | | - BUILD_VERSION=${{ inputs.assembly_version }} |
97 | | - BUILD_FILE_VERSION=${{ inputs.assembly_file_version }} |
98 | | - BUILD_ASSEMBLY_VERSION=${{ inputs.assembly_version }} |
99 | | - BUILD_INFORMATION_VERSION=${{ inputs.assembly_informational_version }} |
100 | | - BUILD_PACKAGE_VERSION=${{ inputs.semver2 }} |
101 | | -
|
102 | | - # Push the trimmed Docker Hub overview from Docker/README.md, main only (one overview, no per-branch context). |
103 | | - - name: Update Docker Hub description step |
104 | | - if: ${{ inputs.push && inputs.branch == 'main' }} |
105 | | - uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0 |
106 | | - with: |
107 | | - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
108 | | - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
109 | | - repository: ptr727/plexcleaner |
110 | | - readme-filepath: ./Docker/README.md |
| 1 | +name: Build Docker image task |
| 2 | + |
| 3 | +# Builds the multi-arch image (linux/amd64,arm64) and, on a main publish, pushes it plus the Docker Hub overview. |
| 4 | +# Branch drives config and tags: main => Release/`latest`, else Debug/`develop`, plus the `:SemVer2` tag. Smoke builds |
| 5 | +# amd64 only and never pushes; registry buildcache is branch-scoped. The orchestrator passes `branch` explicitly |
| 6 | +# (the publisher builds one branch per run - the trigger ref - and smoke passes github.ref_name). |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + # Push the built image and the Docker Hub overview. |
| 11 | + push: |
| 12 | + required: false |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + # Git ref to check out / version (empty = default checkout ref). |
| 16 | + ref: |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + default: '' |
| 20 | + # Logical branch: main => Release/`latest`, else Debug/`develop`. Required (see header). |
| 21 | + branch: |
| 22 | + required: true |
| 23 | + type: string |
| 24 | + # Smoke: build linux/amd64 only, never push, skip the shared cache-to. Fast PR feedback. |
| 25 | + smoke: |
| 26 | + required: false |
| 27 | + type: boolean |
| 28 | + default: false |
| 29 | + # Version from the orchestrator's single NBGV run (threaded). This task does not |
| 30 | + # re-run NBGV on the detached commit, which could classify the branch differently. |
| 31 | + semver2: |
| 32 | + required: true |
| 33 | + type: string |
| 34 | + assembly_version: |
| 35 | + required: true |
| 36 | + type: string |
| 37 | + assembly_file_version: |
| 38 | + required: true |
| 39 | + type: string |
| 40 | + assembly_informational_version: |
| 41 | + required: true |
| 42 | + type: string |
| 43 | + |
| 44 | +jobs: |
| 45 | + |
| 46 | + build-docker: |
| 47 | + name: Build Docker image job |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + steps: |
| 51 | + |
| 52 | + - name: Checkout step |
| 53 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 54 | + with: |
| 55 | + ref: ${{ inputs.ref }} |
| 56 | + |
| 57 | + # QEMU only emulates arm64; smoke is amd64-only, so skip it to save setup cost. |
| 58 | + - name: Setup QEMU step |
| 59 | + if: ${{ !inputs.smoke }} |
| 60 | + uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 |
| 61 | + with: |
| 62 | + platforms: linux/amd64,linux/arm64 |
| 63 | + |
| 64 | + - name: Setup Buildx step |
| 65 | + uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 |
| 66 | + with: |
| 67 | + platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }} |
| 68 | + |
| 69 | + # Always login (even on smoke) for higher pull/cache-read rate limits; the credentials are in both the |
| 70 | + # Actions and Dependabot secret stores so a Dependabot push CI run can log in too. Forks cannot push here. |
| 71 | + - name: Login to Docker Hub step |
| 72 | + uses: docker/login-action@c99871dec2022cc055c062a10cc1a1310835ceb4 # v4.3.0 |
| 73 | + with: |
| 74 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 75 | + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
| 76 | + |
| 77 | + - name: Docker build and push step |
| 78 | + uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 |
| 79 | + with: |
| 80 | + context: . |
| 81 | + push: ${{ inputs.push }} |
| 82 | + file: ./Docker/Dockerfile |
| 83 | + tags: | |
| 84 | + docker.io/ptr727/plexcleaner:${{ inputs.branch == 'main' && 'latest' || 'develop' }} |
| 85 | + docker.io/ptr727/plexcleaner:${{ inputs.semver2 }} |
| 86 | + platforms: ${{ inputs.smoke && 'linux/amd64' || 'linux/amd64,linux/arm64' }} |
| 87 | + # Read both branches' caches (near-identical layers), write only this branch's tag and only when pushing. |
| 88 | + # mode=max caches the builder publish; ignore-error keeps a cache hiccup from failing a publish. |
| 89 | + cache-from: | |
| 90 | + type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-main |
| 91 | + type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-develop |
| 92 | + cache-to: ${{ inputs.push && format('type=registry,ref=docker.io/ptr727/plexcleaner:buildcache-{0},mode=max,ignore-error=true', inputs.branch) || '' }} |
| 93 | + build-args: | |
| 94 | + LABEL_VERSION=${{ inputs.semver2 }} |
| 95 | + BUILD_CONFIGURATION=${{ inputs.branch == 'main' && 'Release' || 'Debug' }} |
| 96 | + BUILD_VERSION=${{ inputs.assembly_version }} |
| 97 | + BUILD_FILE_VERSION=${{ inputs.assembly_file_version }} |
| 98 | + BUILD_ASSEMBLY_VERSION=${{ inputs.assembly_version }} |
| 99 | + BUILD_INFORMATION_VERSION=${{ inputs.assembly_informational_version }} |
| 100 | + BUILD_PACKAGE_VERSION=${{ inputs.semver2 }} |
| 101 | +
|
| 102 | + # Push the trimmed Docker Hub overview from Docker/README.md, main only (one overview, no per-branch context). |
| 103 | + - name: Update Docker Hub description step |
| 104 | + if: ${{ inputs.push && inputs.branch == 'main' }} |
| 105 | + uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0 |
| 106 | + with: |
| 107 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 108 | + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
| 109 | + repository: ptr727/plexcleaner |
| 110 | + readme-filepath: ./Docker/README.md |
0 commit comments