diff --git a/README.md b/README.md index e80efd7..734f6fb 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,24 @@ jobs: install-dependencies: false ``` +## Use a different MSYS2 location + +If you want to integrate with the msys2/setup-msys2 action or otherwise don't have an MSYS2 installation at `C:\msys64`, you can specify a different location for MSYS2: + +```yaml +name: CI +on: [push] +jobs: + build: + runs-on: windows-latest + steps: + - uses: msys2/setup-msys2@v2 + id: setup-msys2 + - uses: mxschmitt/action-tmate@v3 + with: + msys2-location: ${{ steps.setup-msys2.outputs.msys2-location }} +``` + ## Continue a workflow If you want to continue a workflow and you are inside a tmate session, just create a empty file with the name `continue` either in the root directory or in the project directory by running `touch continue` or `sudo touch /continue` (on Linux). diff --git a/action.yml b/action.yml index ee37834..65dad61 100644 --- a/action.yml +++ b/action.yml @@ -45,10 +45,14 @@ inputs: description: 'The ed25519 fingerprint for your tmate server' required: false default: '' + msys2-location: + description: 'The root of the MSYS2 installation (on Windows runners)' + required: false + default: 'C:\msys64' github-token: description: > Personal access token (PAT) used to call into GitHub's REST API. We recommend using a service account with the least permissions necessary. Also when generating a new PAT, select the least scopes necessary. [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) - default: ${{ github.token }} \ No newline at end of file + default: ${{ github.token }} diff --git a/lib/index.js b/lib/index.js index 8985511..574bd0c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -17329,7 +17329,7 @@ const execShellCommand = (cmd, options) => { HOMEBREW_GITHUB_API_TOKEN: core.getInput('github-token') || undefined } }) : - (0,external_child_process_.spawn)("C:\\msys64\\usr\\bin\\bash.exe", ["-lc", cmd], { + (0,external_child_process_.spawn)(`${core.getInput("msys2-location") || "C:\\msys64"}\\usr\\bin\\bash.exe`, ["-lc", cmd], { env: { ...process.env, "MSYS2_PATH_TYPE": "inherit", /* Inherit previous path */ @@ -17638,12 +17638,12 @@ async function run() { } function didTmateQuit() { - const tmateSocketPath = process.platform === "win32" ? "C:/msys64/tmp/tmate.sock" : "/tmp/tmate.sock" + const tmateSocketPath = process.platform === "win32" ? `${core.getInput("msys2-location") || "C:\\msys64"}/tmp/tmate.sock` : "/tmp/tmate.sock" return !external_fs_default().existsSync(tmateSocketPath) } function continueFileExists() { - const continuePath = process.platform === "win32" ? "C:/msys64/continue" : "/continue" + const continuePath = process.platform === "win32" ? `${core.getInput("msys2-location") || "C:\\msys64"}/continue` : "/continue" return external_fs_default().existsSync(continuePath) || external_fs_default().existsSync(external_path_default().join(process.env.GITHUB_WORKSPACE, "continue")) } diff --git a/src/helpers.js b/src/helpers.js index 6660c82..7a53b84 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -28,7 +28,7 @@ export const execShellCommand = (cmd, options) => { HOMEBREW_GITHUB_API_TOKEN: core.getInput('github-token') || undefined } }) : - spawn("C:\\msys64\\usr\\bin\\bash.exe", ["-lc", cmd], { + spawn(`${core.getInput("msys2-location") || "C:\\msys64"}\\usr\\bin\\bash.exe`, ["-lc", cmd], { env: { ...process.env, "MSYS2_PATH_TYPE": "inherit", /* Inherit previous path */ diff --git a/src/index.js b/src/index.js index 7685462..2b0285b 100644 --- a/src/index.js +++ b/src/index.js @@ -252,11 +252,11 @@ export async function run() { } function didTmateQuit() { - const tmateSocketPath = process.platform === "win32" ? "C:/msys64/tmp/tmate.sock" : "/tmp/tmate.sock" + const tmateSocketPath = process.platform === "win32" ? `${core.getInput("msys2-location") || "C:\\msys64"}/tmp/tmate.sock` : "/tmp/tmate.sock" return !fs.existsSync(tmateSocketPath) } function continueFileExists() { - const continuePath = process.platform === "win32" ? "C:/msys64/continue" : "/continue" + const continuePath = process.platform === "win32" ? `${core.getInput("msys2-location") || "C:\\msys64"}/continue` : "/continue" return fs.existsSync(continuePath) || fs.existsSync(path.join(process.env.GITHUB_WORKSPACE, "continue")) }