Update Browserslist Database #4
This file contains 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 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: 138160377+google-site-kit-bot@users.noreply.github.com | |
GIT_AUTHOR_NAME: google-site-kit-bot | |
GIT_COMMITTER_EMAIL: 138160377+google-site-kit-bot@users.noreply.github.com | |
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.GITHUB_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.GITHUB_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.GITHUB_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 |