Skip to content

Commit 1d3122f

Browse files
authored
fix: Restores previous release workflow. (#171)
1 parent 02f2123 commit 1d3122f

File tree

1 file changed

+69
-47
lines changed

1 file changed

+69
-47
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,85 @@
1515
name: Release
1616

1717
on:
18-
push:
18+
push: # Trigger on pushes to main
1919
branches:
2020
- main
2121

2222
jobs:
23-
release:
24-
runs-on: ubuntu-latest
25-
permissions:
26-
contents: write # Needed for pushing to dist
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 (main branch)
32-
uses: actions/checkout@v3
33-
with:
34-
ref: main # Checkout *main*, not dist
35-
token: ${{ secrets.GH_MERGE_TOKEN }}
23+
release:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
id-token: write
28+
env:
29+
GOOGLE_MAPS_JS_SAMPLES_KEY: "${{ secrets.GOOGLE_MAPS_JS_SAMPLES_KEY }}"
30+
steps:
31+
- name: Clear GitHub Actions Cache (Force a Miss)
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.gitconfig
35+
key: gitconfig-${{ github.run_id }}
3636

37-
- name: Clear Git config cache (Global)
38-
run: |
39-
git config --global --unset-all user.name || true
40-
git config --global --unset-all user.email || true
37+
- name: Checkout code
38+
uses: actions/checkout@v3
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Clear Git config cache
43+
run: |
44+
git config --global --unset-all user.name || true
45+
git config --global --unset-all user.email || true
4146
42-
- name: Set Git Identity
43-
run: |
44-
git config --global user.name 'googlemaps-bot'
45-
git config --global user.email '[email protected]'
47+
- name: Set Git Identity
48+
run: |
49+
git config --global user.name 'googlemaps-bot'
50+
git config --global user.email '[email protected]'
4651
47-
- uses: actions/cache@v3
48-
with:
49-
path: ~/.npm
50-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
51-
restore-keys: |
52-
${{ runner.os }}-node
52+
- uses: actions/cache@v3
53+
with:
54+
path: ~/.npm
55+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
56+
restore-keys: |
57+
${{ runner.os }}-node
58+
mode: 'max'
5359
54-
- uses: actions/setup-node@v3
55-
with:
56-
node-version: '22.x'
60+
- uses: actions/setup-node@v3
61+
with:
62+
node-version: '22.x'
5763

58-
- run: npm i
59-
- run: npm run build-all
64+
- run: npm i
65+
- run: npm run build-all
6066

61-
- uses: google-github-actions/auth@v1
62-
with:
63-
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
67+
- uses: google-github-actions/auth@v1
68+
with:
69+
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
6470

65-
- name: Install Firebase CLI
66-
run: npm install -g firebase-tools
71+
- name: Install Firebase CLI
72+
run: npm install -g firebase-tools
6773

68-
- name: Deploy to Firebase Hosting
69-
run: firebase deploy --only hosting
74+
- name: Deploy to Firebase Hosting
75+
run: firebase deploy --only hosting
7076

71-
- name: Force Checkout dist and Overwrite
72-
run: |
73-
git fetch origin main # Ensure we have the latest main
74-
git checkout -B dist origin/main # Force checkout of dist, overwriting with main
75-
git add dist
76-
git commit -m "Update dist folder [skip ci]"
77-
git push --force origin dist # Force push to dist
77+
- name: Check if the dist branch exists remotely
78+
run: |
79+
if git ls-remote --exit-code --heads origin dist; then
80+
# Delete the dist branch locally if it exists
81+
if git show-ref --verify --quiet refs/heads/dist; then
82+
git branch -D dist
83+
fi
84+
# Delete the dist branch remotely
85+
git push origin --delete dist
86+
fi
87+
88+
- name: Checkout and create dist branch from main
89+
run: git checkout -b dist main
90+
91+
- name: Add and commit changes to the dist folder
92+
run: |
93+
git add dist
94+
if [[ -n $(git status --porcelain) ]]; then
95+
git commit -m "Update dist folder"
96+
git push origin dist
97+
else
98+
echo "No changes to commit"
99+
fi

0 commit comments

Comments
 (0)