Skip to content

Commit

Permalink
Add GitHub actions (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronakj authored Sep 14, 2023
1 parent 2bed3b1 commit 82aba97
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 14 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- run: yarn install
- run: yarn lint
- run: yarn vsce:package

- uses: actions/upload-artifact@v3
with:
name: ado-codespaces-tools-vsix
path: ./**.vsix
32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- run: yarn install
- run: yarn lint
- run: yarn vsce:package
- uses: actions/upload-artifact@v3
with:
name: ado-codespaces-tools-vsix
path: ./**.vsix

- run: yarn vsce:publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"esbuild-base": "esbuild ./src/extension.ts ./src/auth-helper.ts --bundle --outdir=out --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
"lint": "eslint src --ext ts",
"lint": "tsc && eslint src --ext ts",
"vsce:package": "vsce package --allow-star-activation",
"vsce:publish": "vsce publish"
"vsce:publish": "vsce publish --allow-star-activation"
},
"dependencies": {
"node-ipc": "^9.0.0",
Expand Down
43 changes: 31 additions & 12 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,38 @@ const authenticateAdo = async (context: vscode.ExtensionContext) => {
}
};

export async function activate(context: vscode.ExtensionContext) {

if (vscode.env.remoteName !== "codespaces") {
vscode.window.showWarningMessage("ADO Codespaces Auth extension is only supported in Github Codespaces", "Uninstall")
.then(async (data) => {
if (data === "Uninstall") {
try {
await vscode.commands.executeCommand("workbench.extensions.uninstallExtension", "ms-codespaces-tools.ado-codespaces-auth")
} catch (err) {
log(err || "");
}
const checkAndWarnIfEnvUnsupported = (): boolean => {
const supportedRemotes = [
"codespaces",
"dev-container",
"attached-container",
];
if (supportedRemotes.includes(vscode.env.remoteName || "")) {
return true;
}
vscode.window
.showWarningMessage(
"ADO Codespaces Auth extension is only supported in Github Codespaces",
"Uninstall"
)
.then(async (data) => {
if (data === "Uninstall") {
try {
await vscode.commands.executeCommand(
"workbench.extensions.uninstallExtension",
"ms-codespaces-tools.ado-codespaces-auth"
);
} catch (err) {
log(err || "");
}
});
}
});
return false;
};

export async function activate(context: vscode.ExtensionContext) {
if (!checkAndWarnIfEnvUnsupported()) {
log("Unsupported env, not enabling extension");
return;
}

Expand Down

0 comments on commit 82aba97

Please sign in to comment.