Skip to content

Update Compat Table

Update Compat Table #3

name: Update Compat Table
permissions: {}
on:
schedule:
# Run weekly on Monday at 00:00 UTC
- cron: "0 0 * * 1"
workflow_dispatch: # Allow manual trigger
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
update:
name: Update compat-table SHA
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
cache-key: warm
components: rustfmt
- name: Get latest compat-table SHA
id: get-sha
run: |
# Clone compat-table repository temporarily to get latest SHA
git clone --depth=1 https://github.com/compat-table/compat-table.git temp-compat-table
LATEST_SHA=$(cd temp-compat-table && git rev-parse HEAD)
echo "latest_sha=$LATEST_SHA" >> $GITHUB_OUTPUT
rm -rf temp-compat-table
echo "Latest compat-table SHA: $LATEST_SHA"
- name: Get current SHA from package.json
id: current-sha
working-directory: tasks/compat_data
run: |
CURRENT_SHA=$(grep -o '#[a-f0-9]*' package.json | sed 's/#//')
echo "current_sha=$CURRENT_SHA" >> $GITHUB_OUTPUT
echo "Current SHA in package.json: $CURRENT_SHA"
- name: Check if update is needed
id: check-update
env:
LATEST_SHA: ${{ steps.get-sha.outputs.latest_sha }}
CURRENT_SHA: ${{ steps.current-sha.outputs.current_sha }}
run: |
if [ "$LATEST_SHA" != "$CURRENT_SHA" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
echo "Update needed: $CURRENT_SHA -> $LATEST_SHA"
else
echo "update_needed=false" >> $GITHUB_OUTPUT
echo "No update needed, SHAs are the same"
fi
- name: Update package.json with new SHA
if: steps.check-update.outputs.update_needed == 'true'
working-directory: tasks/compat_data
env:
LATEST_SHA: ${{ steps.get-sha.outputs.latest_sha }}
CURRENT_SHA: ${{ steps.current-sha.outputs.current_sha }}
run: |
# Update the SHA in package.json
sed -i "s/#$CURRENT_SHA/#$LATEST_SHA/g" package.json
echo "Updated package.json with new SHA"
- name: Install dependencies and run build
if: steps.check-update.outputs.update_needed == 'true'
working-directory: tasks/compat_data
run: |
rm -rf compat-table
pnpm run init
pnpm run build
cargo run -p oxc_compat_data
cargo fmt
- name: Check for changes
if: steps.check-update.outputs.update_needed == 'true'
id: changes
run: |
if git diff --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No files were changed after build"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Files changed:"
git diff --name-only
fi
- name: Create Pull Request
if: steps.check-update.outputs.update_needed == 'true' && steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.OXC_BOT_PAT }}
commit-message: "chore(compat_data): update compat-table to ${{ steps.get-sha.outputs.latest_sha }}"
branch: update-compat-table
branch-suffix: timestamp
base: main
title: "chore(compat_data): update compat-table to latest commit"
assignees: Boshen
body: |
Updates compat-table dependency to the latest commit.
- Previous SHA: `${{ steps.current-sha.outputs.current_sha }}`
- New SHA: `${{ steps.get-sha.outputs.latest_sha }}`