-
Notifications
You must be signed in to change notification settings - Fork 12
135 lines (116 loc) · 4.41 KB
/
release.yml
File metadata and controls
135 lines (116 loc) · 4.41 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release
on:
push:
branches:
- main
paths:
- 'samples/**'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
GOOGLE_MAPS_JS_SAMPLES_KEY: "${{ secrets.GOOGLE_MAPS_JS_SAMPLES_KEY }}"
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GH_MERGE_TOKEN }}
fetch-depth: 0
- name: Set Git Identity
run: |
git config --global user.name 'googlemaps-bot'
git config --global user.email 'googlemaps-bot@google.com'
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- run: npm i
- name: Get Affected Workspaces
id: get_workspaces
run: bash samples/find-changes.sh ${{ github.event.before }}
- name: Build Affected Projects
if: steps.get_workspaces.outputs.changed_workspaces != ''
run: |
IFS=$'\n'
AFFECTED_WORKSPACES_ARRAY=(${STEPS_GET_WORKSPACES_OUTPUTS_CHANGED_WORKSPACES})
echo "Building affected workspaces:"
for workspace in "${AFFECTED_WORKSPACES_ARRAY[@]}"; do
echo " - samples/$workspace"
rm -rf dist/samples/$workspace
(cd samples/ && npm run build --workspace=$workspace)
done
env:
STEPS_GET_WORKSPACES_OUTPUTS_CHANGED_WORKSPACES: ${{ steps.get_workspaces.outputs.changed_workspaces }}
- name: Copy Root Assets to Dist
run: |
if [ -d "assets" ]; then
cp -R assets dist/
fi
- name: Get Deleted Workspaces
id: get_deleted
run: bash samples/find-deleted-subfolders.sh ${{ github.event.before }}
- name: Remove Output for Deleted Folders
if: steps.get_deleted.outputs.deleted_workspaces != ''
run: |
IFS=$'\n'
DELETED_WORKSPACES_ARRAY=({{ steps.get_deleted.outputs.deleted_workspaces }})
echo "Removing deleted project output:"
for workspace in "${DELETED_WORKSPACES_ARRAY[@]}"; do
echo " - samples/$workspace"
rm -rf dist/samples/$workspace
done
- name: Generate Index
run: bash samples/generate-index.sh
- uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Deploy to Firebase Hosting
run: firebase deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
- name: Create temporary branch
run: git checkout -b temp-build-branch
- name: Commit and Push Changes (to temp branch)
id: commit_and_push
run: |
git add dist/ package-lock.json index.html
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
echo "changes_pushed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git commit -m "Update dist folder [skip ci]"
git push --force origin temp-build-branch
echo "changes_pushed=true" >> "$GITHUB_OUTPUT"
- name: Trigger Create Release Workflow
if: steps.commit_and_push.outputs.changes_pushed == 'true'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: dist-pr.yml
ref: 'temp-build-branch'
token: ${{ secrets.GH_APPROVER_TOKEN }} # Use the same token that pushed, it needs 'workflows: write' permissions
inputs: '{ "source_run_id": "${{ github.run_id }}" }' # Optional: Pass the run ID for traceability