Skip to content

Commit 805e618

Browse files
authored
feat: Adds post-build hook. (#96)
* feat: Adds post-build hook. * Update dist-pr.yml Adds missing license header. * Update post-build.sh Adds missing license header.
1 parent 6d5aceb commit 805e618

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

.github/workflows/dist-pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: dist-pr
16+
17+
on:
18+
push:
19+
branches:
20+
- dist # Trigger the workflow on pushes to the dist branch
21+
22+
jobs:
23+
approve-and-merge:
24+
runs-on: ubuntu-latest
25+
if: ${{ github.actor == 'github-actions[bot]' }}
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Create Pull Request
31+
id: cpr
32+
run: |
33+
echo "pull_request_url=$(gh pr create --title "chore: automated output update (dist)" --body "This PR contains updated build output from the dist branch." --base main --head dist)" >> $GITHUB_OUTPUT
34+
35+
- name: Approve PR
36+
run: gh pr review --approve ${{ steps.cpr.outputs.pull_request_url }}
37+
38+
- name: Merge PR
39+
run: gh pr merge --auto --squash --delete-branch ${{ steps.cpr.outputs.pull_request_url }}

.github/workflows/release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
## Runs the release-please action for all new pushes to the main branch.
16-
## This updates the CHANGELOG.md, and uploads the contents of /dist to
17-
## the Cloud bucket. It does NOT release to Node, but it provides
18-
## handy version incrementing which is useful for us.
19-
2015
name: Release
2116

2217
on:
@@ -44,7 +39,7 @@ jobs:
4439
with:
4540
node-version: '22.x'
4641
- run: npm i
47-
- run: npm run build-all
42+
- run: npm run build-prod
4843

4944
- uses: google-github-actions/auth@v1
5045
with:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Samples for the Google Maps JavaScript API.",
55
"scripts": {
66
"build-all": "npm run generate-index && npm run clean && npm run build --workspaces",
7+
"build-prod": "npm run generate-index && npm run clean && npm run build --workspaces && ./.git/hooks/post-build",
78
"clean": "bash samples/clean.sh",
89
"generate-index": "bash samples/generate-index.sh"
910
},

post-build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
# Checkout the dist branch
18+
git checkout dist || git checkout -b dist
19+
20+
# Add and commit the changes to the dist folder
21+
git add dist
22+
git commit -m "Update dist folder"
23+
24+
# Push the changes to the dist branch
25+
git push origin dist

0 commit comments

Comments
 (0)