-
Notifications
You must be signed in to change notification settings - Fork 40
81 lines (69 loc) · 2.68 KB
/
sync.yml
File metadata and controls
81 lines (69 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Sync Webpack
on:
schedule:
# Run every 24 hours at 04:00 UTC
- cron: '0 4 * * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: 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: Create pull request
if: steps.check.outputs.changed == 'true'
uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit-message: 'chore: sync webpack docs to ${{ steps.latest.outputs.latest }}'
title: 'chore: sync webpack docs to ${{ steps.latest.outputs.latest }}'
body: |
Automated update of webpack docs.
- Latest webpack commit: ${{ steps.latest.outputs.latest }}
- Previous commit: ${{ steps.latest.outputs.current }}
branch: 'chore/sync-webpack'