Update Playwright version #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Playwright version | |
| on: | |
| # Runs when manually triggered from the GitHub UI. | |
| workflow_dispatch: | |
| # Runs every day at 04:00 UTC. | |
| schedule: | |
| - cron: '0 4 * * *' | |
| concurrency: | |
| group: update-playwright-version | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| env: | |
| BRANCH_NAME: ci/update-playwright-version | |
| jobs: | |
| update-playwright-version: | |
| name: Update Playwright version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| # Continue an already-open update branch so the bump lands on the existing PR (preserving | |
| # its history, comments and approvals) instead of opening a fresh PR on every run. When no | |
| # update branch exists yet, stay on the default branch so a new one is created below. | |
| - name: Switch to the update branch if it exists | |
| run: | | |
| if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then | |
| git fetch origin "$BRANCH_NAME" | |
| git checkout -B "$BRANCH_NAME" FETCH_HEAD | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: '3.14' | |
| - name: Update Playwright version | |
| run: python scripts/update_playwright_version.py | |
| - name: Detect changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "has-changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has-changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push changes | |
| id: commit-and-push | |
| if: steps.changes.outputs.has-changes == 'true' | |
| uses: apify/actions/signed-commit@v1.4.0 | |
| with: | |
| message: 'chore: update Playwright version in project template' | |
| github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | |
| branch: ${{ env.BRANCH_NAME }} | |
| create-branch: 'true' | |
| - name: Create or update Pull Request | |
| if: steps.commit-and-push.outputs.committed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | |
| run: | | |
| PR_BODY="Automated bump of the Playwright version pinned by the project template Dockerfile. | |
| > Generated by the [Update Playwright version](https://github.com/apify/crawlee-python/actions/workflows/update_playwright_version.yaml) workflow." | |
| PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --base master --json number --jq '.[0].number // empty') | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "Creating new PR" | |
| gh pr create \ | |
| --title "chore: update Playwright version in project template" \ | |
| --body "$PR_BODY" \ | |
| --base master \ | |
| --head "$BRANCH_NAME" | |
| PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --base master --json number --jq '.[0].number // empty') | |
| else | |
| echo "PR #$PR_NUMBER already exists for branch $BRANCH_NAME, updating it" | |
| gh pr edit "$PR_NUMBER" --body "$PR_BODY" | |
| fi | |
| # Enable auto-merge so the PR merges automatically once CI passes. If CI fails, the PR | |
| # stays open for manual review. | |
| echo "Enabling auto-merge for PR #$PR_NUMBER" | |
| gh pr merge "$PR_NUMBER" --auto --squash --delete-branch \ | |
| || echo "::warning::Failed to enable auto-merge. The PR remains open for manual review." |