Skip to content

Commit f16cb0b

Browse files
authored
ci: allow building manually (#427)
1 parent efa4984 commit f16cb0b

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

.github/workflows/docker.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ on:
1010
tags:
1111
- v*.*.*
1212
workflow_dispatch:
13-
inputs: {}
13+
inputs:
14+
version:
15+
description: 'FrankenPHP version'
16+
required: false
17+
type: string
1418
schedule:
1519
- cron: '0 4 * * *'
1620
jobs:
1721
prepare:
1822
runs-on: ubuntu-latest
1923
outputs:
2024
# Push if it's a scheduled job, a tag, or if we're committing to the main branch
21-
push: ${{ toJson(github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) }}
25+
push: ${{ toJson(github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.version) || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) }}
2226
variants: ${{ steps.matrix.outputs.variants }}
2327
platforms: ${{ steps.matrix.outputs.platforms }}
2428
metadata: ${{ steps.matrix.outputs.metadata }}
2529
php_version: ${{ steps.check.outputs.php_version }}
2630
php82_version: ${{ steps.check.outputs.php82_version }}
2731
php83_version: ${{ steps.check.outputs.php83_version }}
2832
skip: ${{ steps.check.outputs.skip }}
29-
ref: ${{ steps.check.outputs.ref }}
33+
ref: ${{ steps.check.outputs.ref || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
3034
steps:
3135
-
3236
name: Check PHP versions
@@ -150,13 +154,13 @@ jobs:
150154
set: |
151155
*.tags=
152156
*.platform=${{ matrix.platform }}
153-
*.cache-from=type=gha,scope=${{ github.ref }}-${{ matrix.platform }}
157+
*.cache-from=type=gha,scope=${{ needs.prepare.outputs.ref || github.ref }}-${{ matrix.platform }}
154158
*.cache-from=type=gha,scope=refs/heads/main-${{ matrix.platform }}
155-
*.cache-to=type=gha,scope=${{ github.ref }}-${{ matrix.platform }},ignore-error=true
159+
*.cache-to=type=gha,scope=${{ needs.prepare.outputs.ref || github.ref }}-${{ matrix.platform }},ignore-error=true
156160
${{ fromJson(needs.prepare.outputs.push) && '*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=true' || '' }}
157161
env:
158162
SHA: ${{ github.sha }}
159-
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || needs.prepare.outputs.ref || github.sha }}
163+
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || needs.prepare.outputs.ref || github.sha }}
160164
PHP_VERSION: ${{ needs.prepare.outputs.php_version }}
161165
-
162166
# Workaround for https://github.com/actions/runner/pull/2477#issuecomment-1501003600

.github/workflows/static.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ on:
1010
tags:
1111
- v*.*.*
1212
workflow_dispatch:
13-
inputs: {}
13+
inputs:
14+
version:
15+
description: 'FrankenPHP version'
16+
required: false
17+
type: string
1418
schedule:
1519
- cron: '0 0 * * *'
1620
jobs:
1721
prepare:
1822
runs-on: ubuntu-latest
1923
outputs:
20-
ref: ${{ steps.ref.outputs.ref }}
24+
ref: ${{ steps.ref.outputs.ref || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
2125
steps:
2226
-
2327
name: Get latest release
@@ -42,7 +46,7 @@ jobs:
4246
version: latest
4347
-
4448
name: Login to DockerHub
45-
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
49+
if: needs.prepare.outputs.ref || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
4650
uses: docker/login-action@v3
4751
with:
4852
username: ${{secrets.REGISTRY_USERNAME}}
@@ -53,27 +57,27 @@ jobs:
5357
uses: docker/bake-action@v4
5458
with:
5559
pull: true
56-
load: ${{toJson(github.event_name != 'schedule' && !startsWith(github.ref, 'refs/tags/') && (github.ref != 'refs/heads/main' || github.event_name == 'pull_request'))}}
57-
push: ${{toJson(github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}}
60+
load: ${{toJson(!needs.prepare.outputs.ref && !startsWith(github.ref, 'refs/tags/') && (github.ref != 'refs/heads/main' || github.event_name == 'pull_request'))}}
61+
push: ${{toJson(needs.prepare.outputs.ref || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}}
5862
targets: static-builder
5963
set: |
60-
*.cache-from=type=gha,scope=${{github.ref}}-static-builder
64+
*.cache-from=type=gha,scope=${{needs.prepare.outputs.ref || github.ref}}-static-builder
6165
*.cache-from=type=gha,scope=refs/heads/main-static-builder
62-
*.cache-to=type=gha,scope=${{github.ref}}-static-builder,ignore-error=true
66+
*.cache-to=type=gha,scope=${{needs.prepare.outputs.ref || github.ref}}-static-builder,ignore-error=true
6367
env:
6468
SHA: ${{github.sha}}
6569
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || github.sha}}
6670
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6771
-
6872
name: Pull Docker image
69-
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
73+
if: needs.prepare.outputs.ref || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
7074
run: docker pull dunglas/frankenphp:static-builder
7175
-
7276
name: Copy binary
7377
run: docker cp "$(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/dist/frankenphp-linux-x86_64" frankenphp-linux-x86_64 ; docker rm static-builder
7478
-
7579
name: Upload asset
76-
if: github.event_name == 'schedule' || github.ref_type == 'tag'
80+
if: needs.prepare.outputs.ref || github.ref_type == 'tag'
7781
run: gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}" frankenphp-linux-x86_64 --repo dunglas/frankenphp --clobber
7882
env:
7983
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -119,7 +123,7 @@ jobs:
119123
run: ./build-static.sh
120124
env:
121125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122-
RELEASE: ${{ (github.event_name == 'schedule' || github.ref_type == 'tag') && '1' || '' }}
126+
RELEASE: ${{ (needs.prepare.outputs.ref || github.ref_type == 'tag') && '1' || '' }}
123127
-
124128
name: Upload artifact
125129
if: github.ref_type == 'branch'

0 commit comments

Comments
 (0)