Skip to content

CSS prefixes

CSS prefixes #1195

name: CSS prefixes
# Controls when the action will run.
on:
schedule:
# * is a special character in YAML so you have to quote this string
# run once a week, on Thursdays at 5:00
- cron: '0 5 * * 4'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
env:
GIT_BRANCH: "master"
GIT_USER_NAME: "macbre"
GIT_USER_EMAIL: "<[email protected]>"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# https://github.com/actions/checkout
- name: Cloning ${{ env.GIT_BRANCH }} branch
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_BRANCH }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: latest
- name: Update prefixes
run: |
npm ci
npm run prefixes
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token
- name: Set up git and gh CLI tool
run: |
echo ${{ secrets.PAT_TOKEN }} | gh auth login --with-token
gh auth status
git config user.name ${GIT_USER_NAME}
git config user.email ${GIT_USER_EMAIL}
- name: Show a diff
run: |
git checkout -- package*
git diff
- name: Commit if needed to a new branch (and create a PR)
continue-on-error: true
run: |
set -x
export PR_BRANCH="prefixes-update"
git checkout -b ${PR_BRANCH}
git add rules/prefixes.json && git checkout -- .
git commit -m "Updating rules/prefixes.json with autoprefixer $(npm list --json | jq -r .dependencies.autoprefixer.version) and browserslist $(npm list --json | jq -r .dependencies.browserslist.version)" \
&& git push origin ${PR_BRANCH} --force \
&& npm version patch \
&& git push origin ${PR_BRANCH} --force \
&& git push --tags \
&& gh pr create \
--assignee macbre \
--label dependencies \
--label "css-prefixes-update" \
--base ${{ env.GIT_BRANCH }} \
--title "Updating prefixes rules" \
--body "rules/prefixes.json bumped"
# e.g. https://github.com/macbre/analyze-css/pull/443
export PR_URL=$(gh pr view prefixes-update --json url | jq -r .url)
echo "::notice::Pull request created: <${PR_URL}>"
# now mark the PR as auto-merged
# automated patch release will happen on merges to master
gh pr merge --auto --merge "$PR_URL"