Skip to content

Update Browser Versions #1084

Update Browser Versions

Update Browser Versions #1084

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
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,
})