-
Notifications
You must be signed in to change notification settings - Fork 42
84 lines (71 loc) · 2.64 KB
/
readmes-updated.yaml
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
82
83
84
name: Check READMEs are up to date
on:
pull_request:
types:
- opened
- synchronize
branches:
- '**'
concurrency:
group:
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/functions/package-lock.json'
- name: Set up global dependencies directory
id: global-deps-setup
run: |
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo "dir=$(npm config get prefix)" >> "$GITHUB_OUTPUT"
- name: Cache global dependencies
uses: actions/cache@v2
with:
path: ${{ steps.global-deps-setup.outputs.dir }}
key:
${{ runner.os }}-npm-global-deps-${{
hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-global-deps-
- name: Install Firebase and Lerna
run: |
echo "${{ steps.global-deps-setup.outputs.dir }}/bin" >> $GITHUB_PATH
npm install -g firebase-tools lerna
- name: Install local dependencies
run: npm ci
- name: Run Lerna generate-readme
run: lerna run --parallel generate-readme
- name: Check READMEs are up to date and push changes if possible.
run: |
changed_files=$(git status -s -- '**/README.md' | cut -c4-)
if [[ ! -z "$changed_files" ]]; then
echo "Changes detected in README.md files:"
echo "$changed_files"
if [[ ${{ github.event.pull_request.head.repo.full_name }} != "GoogleCloudPlatform/firebase-extensions" ]]; then
echo "Please run 'lerna run --parallel generate-readme' locally and commit the changes."
exit 1
fi
git config --global user.name "google-cloud-firebase-extensions-bot"
git config --global user.email "[email protected]"
git checkout ${{ env.BRANCH_NAME }}
git add **/README.md
git commit -m "chore(*): Update READMEs"
git push origin ${{ env.BRANCH_NAME }}
fi