Skip to content

Commit 40858bc

Browse files
authored
fix: Updates workflows to fix some issues. (#165)
1 parent eaad8d8 commit 40858bc

File tree

2 files changed

+68
-93
lines changed

2 files changed

+68
-93
lines changed

.github/workflows/dist-pr.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ on:
2121

2222
jobs:
2323
create-pr:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout code
27-
uses: actions/checkout@v3
28-
with:
29-
ref: ${{ github.event.after }} # Check out the *new* commit on dist
30-
31-
- name: Create Pull Request
32-
uses: peter-evans/create-pull-request@v5
33-
with:
34-
token: ${{ secrets.GH_MERGE_TOKEN }}
35-
commit-message: 'chore: automated output update (dist)'
36-
title: 'chore: automated output update (dist)'
37-
body: 'This PR contains updated build output from the dist branch.'
38-
branch: 'dist-to-main-pr' # Use a dedicated PR branch
39-
base: main
40-
labels: |
41-
automated pr
42-
dist-update
43-
draft: false # Or true, if you want to review before enabling auto-merge
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v3
28+
with:
29+
ref: ${{ github.event.after }} # Check out the *new* commit on dist
30+
token: ${{ secrets.GH_MERGE_TOKEN }} # Use a dedicated PAT!
31+
32+
- name: Create Pull Request
33+
uses: peter-evans/create-pull-request@v5
34+
with:
35+
commit-message: 'chore: automated output update (dist)'
36+
title: 'chore: automated output update (dist)'
37+
body: 'This PR contains updated build output from the dist branch.'
38+
branch: 'dist-to-main-pr' # Use a dedicated PR branch
39+
base: main
40+
labels: |
41+
automated pr
42+
dist-update
43+
draft: false

.github/workflows/release.yml

Lines changed: 48 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,86 +15,61 @@
1515
name: Release
1616

1717
on:
18-
pull_request:
19-
types: [closed]
20-
branches: [main]
18+
push: # Trigger on pushes to main
19+
branches:
20+
- main
2121

2222
jobs:
23-
release:
24-
runs-on: ubuntu-latest
25-
permissions:
26-
contents: write
27-
id-token: write
28-
if: github.event.pull_request.merged == true
29-
env:
30-
GOOGLE_MAPS_JS_SAMPLES_KEY: "${{ secrets.GOOGLE_MAPS_JS_SAMPLES_KEY }}"
31-
steps:
32-
- name: Clear GitHub Actions Cache (Force a Miss)
33-
uses: actions/cache@v3
34-
with:
35-
path: ~/.gitconfig
36-
key: gitconfig-${{ github.run_id }}
23+
release:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
id-token: write # Needed for Firebase deployment
28+
env:
29+
GOOGLE_MAPS_JS_SAMPLES_KEY: "${{ secrets.GOOGLE_MAPS_JS_SAMPLES_KEY }}"
30+
steps:
31+
- name: Checkout code (dist branch)
32+
uses: actions/checkout@v3
33+
with:
34+
repository: ${{ github.repository }} # Be explicit
35+
ref: dist # Checkout the dist branch
36+
token: ${{ secrets.GH_MERGE_TOKEN }} # Use the PAT
3737

38-
- name: Checkout code
39-
uses: actions/checkout@v3
40-
with:
41-
token: ${{ secrets.GITHUB_TOKEN }}
42-
43-
- name: Clear Git config cache
44-
run: |
45-
git config --global --unset-all user.name || true
46-
git config --global --unset-all user.email || true
38+
- name: Merge main into dist
39+
run: |
40+
git fetch origin main:main # Fetch main
41+
git merge --no-ff --allow-unrelated-histories -m "Merge main into dist" main # Merge main into dist
4742
48-
- name: Set Git Identity
49-
run: |
50-
git config --global user.name 'googlemaps-bot'
51-
git config --global user.email '[email protected]'
43+
- uses: actions/cache@v3
44+
with:
45+
path: ~/.npm
46+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-node
5249
53-
- uses: actions/cache@v3
54-
with:
55-
path: ~/.npm
56-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
57-
restore-keys: |
58-
${{ runner.os }}-node
59-
mode: 'max'
50+
- uses: actions/setup-node@v3
51+
with:
52+
node-version: '22.x'
6053

61-
- uses: actions/setup-node@v3
62-
with:
63-
node-version: '22.x'
54+
- run: npm i
55+
- run: npm run build-all
6456

65-
- run: npm i
66-
- run: npm run build-all
57+
- uses: google-github-actions/auth@v1
58+
with:
59+
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
6760

68-
- uses: google-github-actions/auth@v1
69-
with:
70-
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
61+
- name: Install Firebase CLI
62+
run: npm install -g firebase-tools
7163

72-
- name: Install Firebase CLI
73-
run: npm install -g firebase-tools
64+
- name: Deploy to Firebase Hosting
65+
run: firebase deploy --only hosting
7466

75-
- name: Deploy to Firebase Hosting
76-
run: firebase deploy --only hosting
77-
78-
- name: Check if the dist branch exists remotely
79-
run: |
80-
if git ls-remote --exit-code --heads origin dist; then
81-
# Delete the dist branch locally if it exists
82-
if git show-ref --verify --quiet refs/heads/dist; then
83-
git branch -D dist
84-
fi
85-
# Delete the dist branch remotely
86-
git push origin --delete dist
87-
fi
88-
89-
- name: Checkout and create dist branch from main
90-
run: git checkout -b dist main
91-
92-
- name: Add and commit changes to the dist folder
93-
run: |
94-
git add dist
95-
if [[ -n $(git status --porcelain) ]]; then
96-
git commit -m "Update dist folder"
97-
git push origin dist
98-
else
99-
echo "No changes to commit"
100-
fi
67+
- name: Commit and Push Changes (to dist)
68+
run: |
69+
git add dist
70+
if git diff --staged --quiet; then
71+
echo "No changes to commit"
72+
else
73+
git commit -m "Update dist folder [skip ci]"
74+
git push origin dist
75+
fi

0 commit comments

Comments
 (0)