From 4a74600a263c7a194cb5a57d12e40659dc0cb2a1 Mon Sep 17 00:00:00 2001 From: Wei18 <41205mw@gmail.com> Date: Tue, 17 Sep 2024 23:53:55 +0800 Subject: [PATCH] Fix, mint run latest version instead of mintfile --- Actions/Comment/action.yml | 6 ++++-- Actions/Release/action.yml | 6 ++++-- Sources/YamlWriter/CLIYamlBuilder.swift | 24 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Actions/Comment/action.yml b/Actions/Comment/action.yml index 9f7f7a7..22ae230 100644 --- a/Actions/Comment/action.yml +++ b/Actions/Comment/action.yml @@ -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 }} @@ -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 diff --git a/Actions/Release/action.yml b/Actions/Release/action.yml index efe4a1f..190183a 100644 --- a/Actions/Release/action.yml +++ b/Actions/Release/action.yml @@ -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 }} @@ -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 diff --git a/Sources/YamlWriter/CLIYamlBuilder.swift b/Sources/YamlWriter/CLIYamlBuilder.swift index f62c7f0..82403bd 100644 --- a/Sources/YamlWriter/CLIYamlBuilder.swift +++ b/Sources/YamlWriter/CLIYamlBuilder.swift @@ -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) }}" @@ -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() ], ] @@ -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] { @@ -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