|
15 | 15 | name: Release |
16 | 16 |
|
17 | 17 | on: |
18 | | - push: # Trigger on pushes to main |
| 18 | + push: |
19 | 19 | branches: |
20 | 20 | - main |
21 | 21 |
|
22 | 22 | jobs: |
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: Checkout code |
32 | | - uses: actions/checkout@v3 |
33 | | - with: |
34 | | - ref: dist |
35 | | - token: ${{ secrets.GH_MERGE_TOKEN }} |
36 | | - fetch-depth: 0 |
| 23 | + release: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: write |
| 27 | + id-token: write # Needed for Firebase |
| 28 | + env: |
| 29 | + GOOGLE_MAPS_JS_SAMPLES_KEY: "${{ secrets.GOOGLE_MAPS_JS_SAMPLES_KEY }}" |
| 30 | + steps: |
| 31 | + - name: Checkout dist |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + ref: dist # Checkout the *dist* branch initially. |
| 35 | + token: ${{ secrets.GH_MERGE_TOKEN }} |
| 36 | + fetch-depth: 0 |
37 | 37 |
|
38 | | - - name: Set Git Identity |
39 | | - run: | |
40 | | - git config --global user.name 'googlemaps-bot' |
41 | | - git config --global user.email '[email protected]' |
| 38 | + - name: Set Git Identity |
| 39 | + run: | |
| 40 | + git config --global user.name 'googlemaps-bot' |
| 41 | + git config --global user.email '[email protected]' |
| 42 | + |
| 43 | + - name: Fetch main |
| 44 | + run: git fetch origin main:main |
42 | 45 |
|
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 |
| 46 | + - name: Copy Files from Main (Except dist) |
| 47 | + run: | |
| 48 | + git checkout main -- . |
| 49 | + rm -rf dist |
49 | 50 |
|
50 | | - - uses: actions/setup-node@v3 |
51 | | - with: |
52 | | - node-version: '22.x' |
| 51 | + - uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: ~/.npm |
| 54 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 55 | + restore-keys: | |
| 56 | + ${{ runner.os }}-node |
53 | 57 |
|
54 | | - - run: npm i |
55 | | - - run: npm run build-all |
56 | | - |
57 | | - - uses: google-github-actions/auth@v1 |
58 | | - with: |
59 | | - credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }} |
60 | | - |
61 | | - - name: Install Firebase CLI |
62 | | - run: npm install -g firebase-tools |
63 | | - |
64 | | - - name: Deploy to Firebase Hosting |
65 | | - run: firebase deploy --only hosting |
| 58 | + - uses: actions/setup-node@v3 |
| 59 | + with: |
| 60 | + node-version: '22.x' |
66 | 61 |
|
67 | | - - name: Force Checkout dist and Overwrite |
68 | | - run: | |
69 | | - git fetch origin main |
70 | | - git checkout -B dist origin/main |
71 | | - git add dist |
| 62 | + - run: npm i |
| 63 | + - run: npm run build-all |
| 64 | + |
| 65 | + - uses: google-github-actions/auth@v1 |
| 66 | + with: |
| 67 | + credentials_json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_KEY }} |
| 68 | + |
| 69 | + - name: Install Firebase CLI |
| 70 | + run: npm install -g firebase-tools |
| 71 | + |
| 72 | + - name: Deploy to Firebase Hosting |
| 73 | + run: firebase deploy --only hosting |
| 74 | + |
| 75 | + - name: Commit and Push Changes (to dist) |
| 76 | + run: | |
| 77 | + git add dist |
| 78 | + if git diff --staged --quiet; then |
| 79 | + echo "No changes to commit" |
| 80 | + else |
72 | 81 | git commit -m "Update dist folder" |
73 | 82 | git push --force origin dist |
| 83 | + fi |
0 commit comments