1- import crypto from ' node:crypto' ;
2- import fs from ' node:fs/promises' ;
3- import process from ' node:process' ;
4- import * as url from ' node:url' ;
1+ import crypto from " node:crypto" ;
2+ import fs from " node:fs/promises" ;
3+ import process from " node:process" ;
4+ import * as url from " node:url" ;
55import core from "@actions/core" ;
6- import playwright from ' playwright' ;
6+ import playwright from " playwright" ;
77
88export default async function ( ) {
99 core . info ( "Starting 'auth' action" ) ;
@@ -13,32 +13,38 @@ export default async function () {
1313 let page : playwright . Page | undefined ;
1414 try {
1515 // Get inputs
16- const loginUrl = core . getInput ( ' login_url' , { required : true } ) ;
17- const username = core . getInput ( ' username' , { required : true } ) ;
18- const password = core . getInput ( ' password' , { required : true } ) ;
16+ const loginUrl = core . getInput ( " login_url" , { required : true } ) ;
17+ const username = core . getInput ( " username" , { required : true } ) ;
18+ const password = core . getInput ( " password" , { required : true } ) ;
1919 core . setSecret ( password ) ;
2020
2121 // Create a temporary directory for authenticated session state
2222 const actionDirectory = `${ url . fileURLToPath ( new URL ( import . meta. url ) ) } /..` ;
23- const sessionStateDirectory = `${ process . env . RUNNER_TEMP ?? actionDirectory } /.auth/${ crypto . randomUUID ( ) } ` ;
23+ const sessionStateDirectory = `${
24+ process . env . RUNNER_TEMP ?? actionDirectory
25+ } /.auth/${ crypto . randomUUID ( ) } `;
2426 await fs . mkdir ( sessionStateDirectory , { recursive : true } ) ;
2527 const sessionStatePath = `${ sessionStateDirectory } /sessionState.json` ;
2628
2729 // Launch a headless browser
28- browser = await playwright . chromium . launch ( { headless : true , executablePath : process . env . CI ? '/usr/bin/google-chrome' : undefined } ) ;
30+ browser = await playwright . chromium . launch ( {
31+ headless : true ,
32+ executablePath : process . env . CI ? "/usr/bin/google-chrome" : undefined ,
33+ } ) ;
2934 context = await browser . newContext ( ) ;
3035 page = await context . newPage ( ) ;
3136
3237 // Log in
3338 core . info ( "Navigating to login page" ) ;
3439 await page . goto ( loginUrl ) ;
35- core . info ( ' Filling username' ) ;
40+ core . info ( " Filling username" ) ;
3641 await page . getByLabel ( / u s e r n a m e / i) . fill ( username ) ;
37- core . info ( ' Filling password' ) ;
42+ core . info ( " Filling password" ) ;
3843 await page . getByLabel ( / p a s s w o r d / i) . fill ( password ) ;
39- core . info ( 'Logging in' ) ;
40- await page . getByLabel ( / p a s s w o r d / i)
41- . locator ( 'xpath=ancestor::form' )
44+ core . info ( "Logging in" ) ;
45+ await page
46+ . getByLabel ( / p a s s w o r d / i)
47+ . locator ( "xpath=ancestor::form" )
4248 . evaluate ( ( form ) => ( form as HTMLFormElement ) . submit ( ) ) ;
4349
4450 // Write authenticated session state to a file and output its path
0 commit comments