Skip to content

Commit

Permalink
Fix, mint run latest version instead of mintfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei18 committed Sep 17, 2024
1 parent 88d5057 commit 4a74600
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
6 changes: 4 additions & 2 deletions Actions/Comment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ runs:
with:
swift-version: 5.10.0
- name: Create Mintfile
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > ${{ github.action_path }}/Mintfile
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > Mintfile
shell: bash
- name: Setup Mint
uses: irgaly/setup-mint@v1
with:
cache-prefix: GitHubSwiftActions
mint-directory: ${{ github.action_path }}
mint-executable-directory: ~/.mint/bin
- env:
ACTION_REF: ${{ inputs.action_ref }}
Expand All @@ -47,4 +46,7 @@ runs:
name: Run Comment
run: ~/.mint/bin/mint run Wei18/GitHubSwiftActions Comment
shell: bash
- name: Create Mintfile
run: rm Mintfile
shell: bash
using: composite
6 changes: 4 additions & 2 deletions Actions/Release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ runs:
with:
swift-version: 5.10.0
- name: Create Mintfile
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > ${{ github.action_path }}/Mintfile
run: echo Wei18/GitHubSwiftActions@${{ inputs.action_ref }} > Mintfile
shell: bash
- name: Setup Mint
uses: irgaly/setup-mint@v1
with:
cache-prefix: GitHubSwiftActions
mint-directory: ${{ github.action_path }}
mint-executable-directory: ~/.mint/bin
- env:
ACTION_REF: ${{ inputs.action_ref }}
Expand All @@ -43,4 +42,7 @@ runs:
name: Run Release
run: ~/.mint/bin/mint run Wei18/GitHubSwiftActions Release
shell: bash
- name: Create Mintfile
run: rm Mintfile
shell: bash
using: composite
24 changes: 18 additions & 6 deletions Sources/YamlWriter/CLIYamlBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct CLIYamlBuilder {
]
}

inputs.merge(SetUpActionBuilder().buildInputs()) { _, new in new }
let factory = SetUpActionFactory()
inputs.merge(factory.buildInputs()) { _, new in new }

let envDict = inputs.keys.reduce(into: [:]) { partialResult, value in
partialResult[value.uppercased()] = "${{ inputs.\(value) }}"
Expand All @@ -48,14 +49,16 @@ struct CLIYamlBuilder {
"inputs": inputs,
"runs": [
"using": "composite",
"steps": SetUpActionBuilder().buildSteps() + [
"steps": factory.buildSteps() +
[
[
"name": "Run \(name)",
"run": "~/.mint/bin/mint run \(repo) \(name)",
"env": envDict,
"shell": "bash",
],
],
] +
factory.buildPostSteps()
],
]

Expand All @@ -64,7 +67,7 @@ struct CLIYamlBuilder {
}
}

private struct SetUpActionBuilder {
private struct SetUpActionFactory {

/// Workaround: https://github.com/actions/runner/issues/2473#issuecomment-1776051383/
func buildInputs() -> [String: Any] {
Expand All @@ -87,18 +90,27 @@ private struct SetUpActionBuilder {
],
[
"name": "Create Mintfile",
"run": "echo \(content) > ${{ github.action_path }}/Mintfile",
"run": "echo \(content) > Mintfile",
"shell": "bash",
],
[
"name": "Setup Mint",
"uses": "irgaly/setup-mint@v1",
"with": [
"mint-directory": "${{ github.action_path }}",
"mint-executable-directory": "~/.mint/bin",
"cache-prefix": "GitHubSwiftActions",
],
],
]
return action
}

func buildPostSteps() -> [[String: Any]] {
let action: [[String: Any]] = [
[
"name": "Create Mintfile",
"run": "rm Mintfile",
"shell": "bash",
],
]
return action
Expand Down

0 comments on commit 4a74600

Please sign in to comment.