Skip to content

Commit 03e95a8

Browse files
committed
ci: Work around composite actions not supporting default inputs
They kinda do, but the default input values don't get used when the action is called from a workflow, which is like the only way they ever get used...
1 parent b67f5cb commit 03e95a8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

.github/actions/compile-docs/action.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
name: Generate docs
1+
name: Compile docs
22
description: 'A reusable fragment that compiles Swift documentation for a target'
33
inputs:
44
target:
55
description: 'Target to compile documentation for'
66
required: true
77
upload:
8+
# Assumed false if omitted. We could supply the 'default' field, but it doesn't take
9+
# effect when this composite action is called from a workflow, so it would just be
10+
# misleading.
811
description: 'Whether to upload the documentation as an artifact or not'
9-
default: false
1012
xcodebuild:
13+
# Assumed false if omitted
1114
description: 'Whether to use xcodebuild instead of SwiftPM or not'
12-
default: false
1315
xcodebuild-device-type:
16+
# Assumed 'Mac' if omitted
1417
description: 'The device type to compile docs for when using xcodebuild (e.g. iPhone, iPad or TV)'
15-
default: "Mac"
1618
runs:
1719
using: "composite"
1820
steps:
1921
- name: Compile documentation (with SwiftPM)
20-
if: ${{ !inputs.xcodebuild }}
22+
if: ${{ inputs.xcodebuild != true }} # Compare to constant to treat empty input as false
2123
run: |
2224
swift package \
2325
--allow-writing-to-directory "$TARGET.doccarchive" \
@@ -34,9 +36,10 @@ runs:
3436
env:
3537
TARGET: ${{ inputs.target }}
3638
- name: Compile documentation (with xcodebuild)
37-
if: ${{ inputs.xcodebuild }}
39+
if: ${{ inputs.xcodebuild == true }} # Compare to constant to treat empty input as false
3840
run: |
39-
if [ $DEVICE_TYPE -eq "Mac" ]; then
41+
destination=""
42+
if [[ $DEVICE_TYPE == "Mac" ]] || [[ $DEVICE_TYPE == "" ]]; then
4043
destination="platform=OS X"
4144
else
4245
destination="id=$(xcrun simctl list devices $devicetype available | grep -v -- -- | tail -n 1 | grep -oE '[0-9A-F\-]{36}')"
@@ -47,7 +50,7 @@ runs:
4750
TARGET: ${{ inputs.target }}
4851
DEVICE_TYPE: ${{ inputs.xcodebuild-device-type }}
4952
- uses: actions/upload-artifact@v4
50-
if: ${{ inputs.upload }}
53+
if: ${{ inputs.upload == true }} # Compare to constant to treat empty input as false
5154
with:
5255
name: ${{ inputs.target }}.doccarchive
5356
path: ${{ inputs.target }}.doccarchive

0 commit comments

Comments
 (0)