While running the schedule-playwright.yml
github actions workflow, getting following error SyntaxError: Identifier 'github' has already been declared
Could someone please advise how can I fix this issue ?
note: playwright.yml file is running successfully.
//schedule-playwright.yml
name: Scheduled 11:16 PM Playwright e2e Test run
on:
schedule:
- cron: '16 13 * * *' # This is UTC time; 10:35 PM AEST is 12:35 PM UTC
jobs:
trigger_playwright:
runs-on: ubuntu-latest
steps:
- name: Trigger Playwright e2e Tests workflow
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { github } = require('@actions/github');
async function run() {
try {
await github.getOctokit(process.env.GITHUB_TOKEN).actions.createWorkflowDispatch({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
workflow_id: 'playwright.yml',
ref: 'main'
});
console.log('Workflow dispatched successfully');
} catch (error) {
console.error('Error dispatching workflow:', error);
}
}
run();
//playwright.yml file
name: Playwright e2e Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: |
npx playwright test 2>&1 | while IFS= read -r line; do
echo "$line"
done
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30