Update Browserslist Database #39
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 | |
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: Configure git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- 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 |