Skip to content

Sync Webpack

Sync Webpack #12

Workflow file for this run

name: Sync Webpack
on:
schedule:
# Run every 24 hours at 04:00 UTC
- cron: "0 4 * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get latest webpack commit
id: latest
run: |
LATEST=$(git ls-remote https://github.com/webpack/webpack.git refs/heads/main | cut -f1)
CURRENT=$(cat HEAD_COMMIT)
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "Latest webpack commit: $LATEST"
echo "Current pinned commit: $CURRENT"
- name: Check for changes
id: check
run: |
if [ "${{ steps.latest.outputs.latest }}" = "${{ steps.latest.outputs.current }}" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes detected, skipping sync."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "New webpack commit detected, syncing."
fi
- name: Checkout webpack
if: steps.check.outputs.changed == 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: webpack/webpack
ref: ${{ steps.latest.outputs.latest }}
path: webpack
- name: Setup Node.js
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: lts/*
cache: "npm"
- name: Install dependencies
if: steps.check.outputs.changed == 'true'
run: npm ci
- name: Update HEAD_COMMIT
if: steps.check.outputs.changed == 'true'
run: echo "${{ steps.latest.outputs.latest }}" > HEAD_COMMIT
- name: Regenerate docs
if: steps.check.outputs.changed == 'true'
run: npm run generate-docs
- name: Commit and push
if: steps.check.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add HEAD_COMMIT pages/
git commit -m "chore: sync webpack docs to $(echo ${{ steps.latest.outputs.latest }} | cut -c1-7)"
git push