Skip to content

Commit

Permalink
gcp auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarsh2001 committed Oct 4, 2023
1 parent c0d030a commit abe306b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/auth/vm_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def authenticate_vm(path):
credentials = Credentials.from_service_account_file(path)
return discovery.build('compute', 'v1', credentials=credentials), credentials
def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'):
def start_runner(creds, key, id = "gpu-insatnce", zone='us-central1-a', instance='demos-tests'):
compute, credentials = authenticate_vm(creds)
compute.instances().start(project=id, zone=zone, instance=instance).execute()
# request = compute.instances().get(project=id, zone=zone, instance=instance)
Expand All @@ -27,7 +27,7 @@ def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instanc
ssh.connect(
hostname=f'{instance}.{zone}.compute.internal',
username=ssh_username, # Typically 'your-username' or 'gce-username'
key_filename= 'gcp_auth.pem',
pkey = paramiko.RSAKey(file_obj=key),
)


Expand All @@ -43,9 +43,9 @@ def start_runner(creds, user, id = "gpu-insatnce", zone='us-central1-a', instanc
return output

if __name__ == "__main__":
user = sys.argv[1]
key = sys.argv[1]
# Start the instance
start_runner('gcp_auth.json', user)
start_runner('gcp_auth.json', key)



3 changes: 1 addition & 2 deletions .github/workflows/gcp-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ jobs:
run: |
cd demos/.github/auth
python3 db_auth.py ${{ secrets.DB_ENDPOINT }} ${{ secrets.DB_OBJ_ID }}
openssl pkcs8 -inform PEM -outform PEM -in gcp_auth.json -out gcp_auth.pem
python3 vm_auth.py ${{ secrets.SSH_USERNAME}}
python3 vm_auth.py ${{ secrets.SSH_KEY}}
run-test:
needs: activate-vm
Expand Down

0 comments on commit abe306b

Please sign in to comment.