Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 14 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 16 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,27 @@ export const run = async (): Promise<void> => {
* 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)
])

Expand Down