-
Notifications
You must be signed in to change notification settings - Fork 792
97 lines (81 loc) · 3.47 KB
/
Copy pathupdate_playwright_version.yaml
File metadata and controls
97 lines (81 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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."