Skip to content

fix: Fixes various HTML issues prior to formatting. (#961) #423

fix: Fixes various HTML issues prior to formatting. (#961)

fix: Fixes various HTML issues prior to formatting. (#961) #423

Workflow file for this run

# 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@v3
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 '[email protected]'
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- uses: actions/setup-node@v3
with:
node-version: '22.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
- 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