diff --git a/README.md b/README.md index 53121dd..56cba20 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ jobs: with: machineName: myMachine # optional, default: GitHub workflow run ID timeout: '30000' # optional, default: 30000 + installExtensions: | + ms-python.python + ``` In case your build fails the action attempts to start a VS Code Server on the build machine and requests you to authorize it: @@ -50,6 +53,11 @@ You can also connect to it through your local VS Code application. Just open the - `machineName` (optional): name of the machine to access (default: GitHub Action run id) - `timeout` (optional): the time until the action continues the build if the machine does not get authorized (default: 30s) +- `installExtensions` (optional): a newline-separated list of extensions to install on the server (default: empty) + +For extensions use the [VS Code Marketplace](https://marketplace.visualstudio.com/vscode) identifier, e.g. `ms-python.python` for the Python extension. + +You can also pin versions as described [here](https://code.visualstudio.com/docs/configure/command-line#_working-with-extensions). ## Contribute diff --git a/action.yml b/action.yml index 5170dcb..3b46907 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,9 @@ inputs: description: 'The time until the action continues the build of the machine does not get authorised' required: true default: '30000' # 30s + installExtensions: + description: 'A newline-separated list of extensions to install. Use the syntax for the extensions described here: https://code.visualstudio.com/docs/configure/command-line#_working-with-extensions' + required: false runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 7e19f79..f4077e5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -24946,11 +24946,23 @@ const run = async () => { * name the machine as an individual command so that we don't * get prompt when launching the server */ - console.log('RUN', codePath, ['tunnel', '--accept-server-license-terms', 'rename', machineId].join(' ')); + const installExtensions = (0,_actions_core__WEBPACK_IMPORTED_MODULE_4__.getInput)('installExtensions'); + const extensionsList = installExtensions.split(/\r?\n/).filter(Boolean); + const extensionsArgs = extensionsList.map((extension) => ['--install-extension', extension]).flat(); + const forceInstallExtensionArg = extensionsList.length > 0 ? ['--force'] : []; + const execArgs = [ + 'tunnel', + '--accept-server-license-terms', + ...extensionsArgs, + ...forceInstallExtensionArg, + 'rename', + machineId, + ]; + console.log('RUN', codePath, execArgs.join(' ')); await (0,execa__WEBPACK_IMPORTED_MODULE_2__/* .execa */ .r)(codePath, ['--help']); const startServer = await Promise.race([ new Promise((resolve) => setTimeout(() => resolve(false), timeout)), - (0,execa__WEBPACK_IMPORTED_MODULE_2__/* .execa */ .r)(codePath, ['tunnel', '--accept-server-license-terms', 'rename', machineId]).then(() => true) + (0,execa__WEBPACK_IMPORTED_MODULE_2__/* .execa */ .r)(codePath, execArgs).then(() => true) ]); console.log(5); if (!startServer) { diff --git a/src/main.ts b/src/main.ts index 0b26cf6..3c8922b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,13 +40,27 @@ export const run = async (): Promise => { * name the machine as an individual command so that we don't * get prompt when launching the server */ - console.log('RUN', codePath, ['tunnel', '--accept-server-license-terms', 'rename', machineId].join(' ')); + const installExtensions = getInput('installExtensions') + const extensionsList = installExtensions.split(/\r?\n/).filter(Boolean) + const extensionsArgs = extensionsList.map((extension) => ['--install-extension', extension]).flat() + const forceInstallExtensionArg = extensionsList.length > 0 ? ['--force'] : [] + + const execArgs = [ + 'tunnel', + '--accept-server-license-terms', + ...extensionsArgs, + ...forceInstallExtensionArg, + 'rename', + machineId, + ] + + console.log('RUN', codePath, execArgs.join(' ')); await execa(codePath, ['--help']) const startServer = await Promise.race([ new Promise((resolve) => setTimeout(() => resolve(false), timeout)), execa( codePath, - ['tunnel', '--accept-server-license-terms', 'rename', machineId] + execArgs ).then(() => true) ])