Skip to content

Update Browserslist Database #58

Update Browserslist Database

Update Browserslist Database #58

name: Update Browserslist Database
on:
schedule:
# Run workflow every Sunday at 00:00
- cron: '0 0 * * 0'
workflow_dispatch:
env:
branch-name: update/browserslist-db
GIT_AUTHOR_EMAIL: [email protected]
GIT_AUTHOR_NAME: google-site-kit-bot
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: google-site-kit-bot
jobs:
close-existing-pr:
name: Close existing PR
runs-on: ubuntu-latest
steps:
- name: Check if branch exists
id: check-branch
continue-on-error: true
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${{ env.branch-name }}'
method: 'GET'
bearerToken: ${{ secrets.GH_BOT_TOKEN }}
customHeaders: '{"Accept": "application/vnd.github+json"}'
- name: Delete branch
id: delete-branch
if: steps.check-branch.outcome == 'success'
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.github.com/repos/${{ github.repository }}/git/refs/heads/${{ env.branch-name }}'
method: 'DELETE'
bearerToken: ${{ secrets.GH_BOT_TOKEN }}
customHeaders: '{"Accept": "application/vnd.github+json"}'
outputs:
check-branch-status: ${{ steps.check-branch.outputs.requestError && fromJson( steps.check-branch.outputs.requestError ).status || false }}
delete-branch-outcome: ${{ steps.delete-branch.outcome }}
update-browserslist-database:
name: Create PR containing Browserslist updates
needs: close-existing-pr
if: ${{ needs.close-existing-pr.outputs.delete-branch-outcome == 'success' || needs.close-existing-pr.outputs.check-branch-status == '404' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Update Browserslist database and create PR if applicable
uses: c2corg/browserslist-update-action@v1
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
branch: ${{ env.branch-name }}
commit_message: 'Update Browserslist database.'
title: 'Update Browserslist Database'
body: Auto-generated by [browserslist-update-action](https://github.com/c2corg/browserslist-update-action/)
base_branch: develop