Skip to content

Commit d0919d6

Browse files
authored
fix: Restores most of original release.yml. (#169)
1 parent 2d48534 commit d0919d6

File tree

1 file changed

+67
-53
lines changed

1 file changed

+67
-53
lines changed

.github/workflows/release.yml

Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,66 +20,80 @@ on:
2020
- main
2121

2222
jobs:
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
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 }}
3736

38-
- name: Clear Git config cache (Global) # Keep this!
39-
run: |
40-
git config --global --unset-all user.name || true
41-
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
4246
43-
- name: Set Git Identity # Keep this!
44-
run: |
45-
git config --global user.name 'googlemaps-bot'
46-
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]'
4751
48-
- name: Merge main into dist
49-
run: |
50-
git fetch origin main:main # Fetch main
51-
git merge --no-ff --allow-unrelated-histories -m "Merge main into dist" main # Merge main into dist
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'
5259
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
60+
- uses: actions/setup-node@v3
61+
with:
62+
node-version: '22.x'
5963

60-
- uses: actions/setup-node@v3
61-
with:
62-
node-version: '22.x'
64+
- run: npm i
65+
- run: npm run build-all
6366

64-
- run: npm i
65-
- run: npm run build-all
67+
- uses: google-github-actions/auth@v1
68+
with:
69+
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
6670

67-
- uses: google-github-actions/auth@v1
68-
with:
69-
credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }}
71+
- name: Install Firebase CLI
72+
run: npm install -g firebase-tools
7073

71-
- name: Install Firebase CLI
72-
run: npm install -g firebase-tools
74+
- name: Deploy to Firebase Hosting
75+
run: firebase deploy --only hosting
7376

74-
- name: Deploy to Firebase Hosting
75-
run: firebase deploy --only hosting
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
7687
77-
- name: Commit and Push Changes (to dist)
78-
run: |
79-
git add dist
80-
if git diff --staged --quiet; then
81-
echo "No changes to commit"
82-
else
83-
git commit -m "Update dist folder [skip ci]"
84-
git push origin dist
85-
fi
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)