Skip to content

Commit 966ead2

Browse files
committed
Workaround, github.action_ref are empty, ref: actions/runner#2473
1 parent dc7323f commit 966ead2

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Actions/Comment/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
description: Runs the process of adding or updating a comment in a GitHub issue or pull request.
22
inputs:
3+
action_ref:
4+
default: ${{ github.action_ref }}
35
anchor:
46
description: The anchor for the command.
57
required: true
@@ -26,7 +28,7 @@ runs:
2628
with:
2729
swift-version: 5.10.0
2830
- name: Create Mintfile
29-
run: echo Wei18/GitHubSwiftActions@${{ github.action_ref }} > ${{ github.action_path }}/Mintfile
31+
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > ${{ github.action_path }}/Mintfile
3032
shell: bash
3133
- name: Setup Mint
3234
uses: irgaly/setup-mint@v1
@@ -35,6 +37,7 @@ runs:
3537
mint-directory: ${{ github.action_path }}
3638
mint-executable-directory: ~/.mint/bin
3739
- env:
40+
ACTION_REF: ${{ inputs.action_ref }}
3841
ANCHOR: ${{ inputs.anchor }}
3942
BODY: ${{ inputs.body }}
4043
NUMBER: ${{ inputs.number }}

Actions/Release/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
description: Runs the process of creating GitHub Release with bump type and git ref
22
inputs:
3+
action_ref:
4+
default: ${{ github.action_ref }}
35
owner:
46
description: The owner for the command.
57
required: true
@@ -23,7 +25,7 @@ runs:
2325
with:
2426
swift-version: 5.10.0
2527
- name: Create Mintfile
26-
run: echo Wei18/GitHubSwiftActions@${{ github.action_ref }} > ${{ github.action_path }}/Mintfile
28+
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > ${{ github.action_path }}/Mintfile
2729
shell: bash
2830
- name: Setup Mint
2931
uses: irgaly/setup-mint@v1
@@ -32,6 +34,7 @@ runs:
3234
mint-directory: ${{ github.action_path }}
3335
mint-executable-directory: ~/.mint/bin
3436
- env:
37+
ACTION_REF: ${{ inputs.action_ref }}
3538
OWNER: ${{ inputs.owner }}
3639
REF: ${{ inputs.ref }}
3740
REPO: ${{ inputs.repo }}

Sources/YamlWriter/CLIYamlBuilder.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ struct CLIYamlBuilder {
3232
]
3333
}
3434

35+
inputs.merge(SetUpActionBuilder().buildInputs()) { _, new in new }
36+
3537
let envDict = inputs.keys.reduce(into: [:]) { partialResult, value in
3638
partialResult[value.uppercased()] = "${{ inputs.\(value) }}"
3739
}
@@ -46,7 +48,7 @@ struct CLIYamlBuilder {
4648
"inputs": inputs,
4749
"runs": [
4850
"using": "composite",
49-
"steps": SetUpActionBuilder().build() + [
51+
"steps": SetUpActionBuilder().buildSteps() + [
5052
[
5153
"name": "Run \(name)",
5254
"run": "~/.mint/bin/mint run \(repo) \(name)",
@@ -63,8 +65,18 @@ struct CLIYamlBuilder {
6365
}
6466

6567
private struct SetUpActionBuilder {
66-
func build() -> [[String: Any]] {
67-
let content = "\(SwiftPackageConfig.current.repo)@${{ github.action_ref }}"
68+
69+
/// Workaround: https://github.com/actions/runner/issues/2473#issuecomment-1776051383/
70+
func buildInputs() -> [String: Any] {
71+
return [
72+
"action_ref": [
73+
"default": "${{ github.action_ref }}"
74+
]
75+
]
76+
}
77+
78+
func buildSteps() -> [[String: Any]] {
79+
let content = "\(SwiftPackageConfig.current.repo)@${{ inputs.action_ref }}"
6880
let action: [[String: Any]] = [
6981
[
7082
"name": "Setup Swift",

0 commit comments

Comments
 (0)