-
Notifications
You must be signed in to change notification settings - Fork 3.2k
126 lines (120 loc) · 5.88 KB
/
update-browser-versions.yml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Update Browser Versions
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * *' # every day at 8am UTC (3/4am EST/EDT)
jobs:
update-browser-versions:
runs-on: ubuntu-latest
env:
CYPRESS_BOT_APP_ID: ${{ secrets.CYPRESS_BOT_APP_ID }}
BASE_BRANCH: develop
# Prevent from running this workflow on forks
if: github.repository == 'cypress-io/cypress'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.BOT_GITHUB_ACTION_TOKEN }}
- name: Set committer info
## attribute the commit to cypress-bot: https://github.community/t/logging-into-git-as-a-github-app/115916
run: |
git config --local user.email "${{ env.CYPRESS_BOT_APP_ID }}+cypress-bot[bot]@users.noreply.github.com"
git config --local user.name "cypress-bot[bot]"
- name: Checkout base branch
run: |
git fetch origin
git checkout ${{ env.BASE_BRANCH }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Check for new Chrome versions
id: get-versions
uses: actions/github-script@v7
with:
script: |
const { getVersions } = require('./scripts/github-actions/update-browser-versions.js')
getVersions({ core })
- name: Determine name of new branch and if it already exists
id: check-branch
env:
BRANCH_NAME: update-chrome-stable-from-${{ steps.get-versions.outputs.current_stable_version }}-beta-from-${{ steps.get-versions.outputs.current_beta_version }}
run: |
echo "branch_name=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT
echo "branch_exists=$(git show-ref --verify --quiet refs/remotes/origin/${{ env.BRANCH_NAME }} && echo 'true')" >> $GITHUB_OUTPUT
- name: Check need for PR or branch update
id: check-need-for-pr
run: |
echo "needs_pr=${{ steps.get-versions.outputs.has_update == 'true' && steps.check-branch.outputs.branch_exists != 'true' }}" >> $GITHUB_OUTPUT
echo "needs_branch_update=${{ steps.get-versions.outputs.has_update == 'true' && steps.check-branch.outputs.branch_exists == 'true' }}" >> $GITHUB_OUTPUT
## Update available and a branch/PR already exists
- name: Checkout existing branch
if: ${{ steps.check-need-for-pr.outputs.needs_branch_update == 'true' }}
run: git checkout ${{ steps.check-branch.outputs.branch_name }}
- name: Check need for update on existing branch
if: ${{ steps.check-need-for-pr.outputs.needs_branch_update == 'true' }}
id: check-need-for-branch-update
uses: actions/github-script@v7
with:
script: |
const { checkNeedForBranchUpdate } = require('./scripts/github-actions/update-browser-versions.js')
checkNeedForBranchUpdate({
core,
latestStableVersion: '${{ steps.get-versions.outputs.latest_stable_version }}',
latestBetaVersion: '${{ steps.get-versions.outputs.latest_beta_version }}',
})
## Update available and a PR doesn't already exist
- name: Checkout new branch
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' }}
run: git checkout -b ${{ steps.check-branch.outputs.branch_name }} ${{ env.BASE_BRANCH }}
## Both
- name: Update Browser Versions File
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' || steps.check-need-for-branch-update.outputs.has_newer_update == 'true' }}
uses: actions/github-script@v7
with:
script: |
const { updateBrowserVersionsFile } = require('./scripts/github-actions/update-browser-versions.js')
updateBrowserVersionsFile({
latestStableVersion: '${{ steps.get-versions.outputs.latest_stable_version }}',
latestBetaVersion: '${{ steps.get-versions.outputs.latest_beta_version }}',
})
- name: Commit the changes
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' || steps.check-need-for-branch-update.outputs.has_newer_update == 'true' }}
run: |
git commit -am "chore: ${{ steps.get-versions.outputs.description }}"
- name: Push branch to remote
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' || steps.check-need-for-branch-update.outputs.has_newer_update == 'true' }}
run: git push origin ${{ steps.check-branch.outputs.branch_name }}
## Update available and a branch/PR already exists
- name: Update PR Title
if: ${{ steps.check-need-for-pr.outputs.needs_branch_update == 'true' }}
uses: actions/github-script@v7
with:
script: |
const { updatePRTitle } = require('./scripts/github-actions/update-browser-versions.js')
await updatePRTitle({
context,
github,
baseBranch: '${{ env.BASE_BRANCH }}',
branchName: '${{ steps.check-branch.outputs.branch_name }}',
description: '${{ steps.get-versions.outputs.description }}',
})
# Update available and a PR doesn't already exist
- name: Create Pull Request
id: create-pr
if: ${{ steps.check-need-for-pr.outputs.needs_pr == 'true' }}
uses: actions/github-script@v7
with:
script: |
const { createPullRequest } = require('./scripts/github-actions/create-pull-request.js')
await createPullRequest({
context,
github,
baseBranch: '${{ env.BASE_BRANCH }}',
branchName: '${{ steps.check-branch.outputs.branch_name }}',
description: '${{ steps.get-versions.outputs.description }}',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
addToProjectBoard: true,
})