From b7a1b9b56447154187a394b0215a053e807a4f66 Mon Sep 17 00:00:00 2001 From: Atharva Mulmuley Date: Tue, 4 May 2021 12:36:21 +0530 Subject: [PATCH] trying with az login as separate action --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++++++++++++++ lib/arc-login.js | 2 +- lib/main.js | 1 + src/arc-login.ts | 2 +- src/main.ts | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..ad0d1959 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +# This is a basic workflow to help you get started with Actions + +name: k8s-set-context + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ cluster-connect-2 ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + #runs-on: ubuntu-latest + runs-on: self-hosted + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDS }} + + - uses: atharvamulmuley/k8s-set-context@cluster-connect-2 + with: + method: 'service-account' + cluster-type: 'arc' + creds: '${{ secrets.AZURE_CREDS }}' + cluster-name: arcaction + resource-group: atharvatest2 + token: '${{ secrets.SA_TOKEN }}' + - run: | + kubectl get pods -A \ No newline at end of file diff --git a/lib/arc-login.js b/lib/arc-login.js index 9c9ea0bc..0f622d60 100644 --- a/lib/arc-login.js +++ b/lib/arc-login.js @@ -70,7 +70,7 @@ function getArcKubeconfig() { if (!clusterName) { throw Error("'clusterName' is not passed for arc cluster."); } - yield az_login.main(); + //await az_login.main(); yield az_login.executeAzCliCommand(`account show`, false); try { yield az_login.executeAzCliCommand(`extension remove -n connectedk8s`, false); diff --git a/lib/main.js b/lib/main.js index 0005e04c..03f86161 100644 --- a/lib/main.js +++ b/lib/main.js @@ -124,6 +124,7 @@ function main() { exports.main = main; function executeAzCliCommand(command, silent, execOptions = {}, args = []) { return __awaiter(this, void 0, void 0, function* () { + azPath = yield io.which("az", true); execOptions.silent = !!silent; try { yield exec.exec(`"${azPath}" ${command}`, args, execOptions); diff --git a/src/arc-login.ts b/src/arc-login.ts index 0fd06855..db08b416 100644 --- a/src/arc-login.ts +++ b/src/arc-login.ts @@ -65,7 +65,7 @@ export async function getArcKubeconfig(): Promise { if(!clusterName){ throw Error("'clusterName' is not passed for arc cluster.") } - await az_login.main(); + //await az_login.main(); await az_login.executeAzCliCommand(`account show`, false); try{ await az_login.executeAzCliCommand(`extension remove -n connectedk8s`, false); diff --git a/src/main.ts b/src/main.ts index e75c80db..10f86c0c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -133,7 +133,7 @@ export async function executeAzCliCommand( silent?: boolean, execOptions: any = {}, args: any = []) { - + azPath = await io.which("az", true); execOptions.silent = !!silent; try { await exec.exec(`"${azPath}" ${command}`, args, execOptions);