trying with az login as separate action

This commit is contained in:
Atharva Mulmuley 2021-05-04 12:36:21 +05:30
parent aff8b97341
commit b7a1b9b564
5 changed files with 43 additions and 3 deletions

39
.github/workflows/main.yml vendored Normal file
View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -65,7 +65,7 @@ export async function getArcKubeconfig(): Promise<string> {
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);

View File

@ -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);