Example Playwright script to login to GitHub
There is a GitHub workflow that runs this script on push to main.
You need to create the following Actions secrets in your GitHub repo where this workflow is located:
- GH_TOTP This is the 2FA token for of the GitHub machine user. You can get this setup key when you setup 2fa as per the docs.
- GITHUB_USERNAME This is the GitHub username of the machine user.
- GITHUB_PASSWORD This is your GitHub password of the machine user.
Create a .env file with the following variables:
GH_USERNAME=username
GH_PASSWORD=pwd
GH_TOTP=AAAXXXBBBXXXCCCA
To run locally, you can use the Playwright extension for VSCode or the following command:
npx playwright test
You can record tests as per these instructions
It is recommended to use a GitHub personal access token instead of your password for interactions with GitHub.