|
1 | 1 | # Deploy to Firebase |
2 | 2 |
|
3 | | -A GitHub Action to deploy to Firebase Hosting |
| 3 | +A GitHub Action to deploy to Firebase Hosting. |
4 | 4 |
|
5 | | -- You can choose a specific branch to allow deployment by using the `TARGET_BRANCH` env var (`master` if not specified). |
6 | | -- Make sure you have the `firebase.json` file in the repository |
7 | | -- Get the Firebase token by running `firebase login:ci` and [store it](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) as the `FIREBASE_TOKEN` secret |
8 | | -- Set the project name in the `FIREBASE_PROJECT` env var |
| 5 | +- Make sure that you checkout the repository using the [actions/checkout](https://github.com/actions/checkout) action |
| 6 | +- Make sure that you have the `firebase.json` file in the repository |
| 7 | +- To obtain the Firebase token, run `firebase login:ci` on your local computer and [store the token](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) as the `FIREBASE_TOKEN` secret |
| 8 | +- Specify the Firebase project name in the `FIREBASE_PROJECT` env var |
9 | 9 |
|
10 | | -Example workflow |
| 10 | +## Workflow examples |
| 11 | + |
| 12 | +Deploy the `main` branch when a commit is pushed to it: |
11 | 13 |
|
12 | 14 | ``` |
13 | | -name: Build and Deploy |
| 15 | +name: Deploy the main branch |
14 | 16 | on: |
15 | 17 | push: |
16 | 18 | branches: |
17 | | - - main |
| 19 | + - main |
| 20 | +jobs: |
| 21 | + main: |
| 22 | + name: Deploy to Firebase |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - uses: lowply/deploy-firebase@v0.0.5 |
| 27 | + env: |
| 28 | + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} |
| 29 | + FIREBASE_PROJECT: name-of-the-project |
| 30 | +``` |
| 31 | + |
| 32 | +Deploy only when a tag starts with `v` is pushed: |
| 33 | + |
| 34 | +``` |
| 35 | +name: Deploy a tag |
| 36 | +on: |
| 37 | + push: |
| 38 | + tags: |
| 39 | + - v* |
18 | 40 | jobs: |
19 | 41 | main: |
20 | | - name: Build and Deploy |
| 42 | + name: Deploy to Firebase |
21 | 43 | runs-on: ubuntu-latest |
22 | 44 | steps: |
23 | | - - name: Check out code |
24 | | - uses: actions/checkout@master |
25 | | - - name: Build Hugo |
26 | | - uses: lowply/build-hugo@v0.68.3 |
27 | | - - name: Deploy to Firebase |
28 | | - uses: lowply/deploy-firebase@v0.0.3 |
| 45 | + - uses: actions/checkout@v2 |
| 46 | + - uses: lowply/deploy-firebase@v0.0.5 |
29 | 47 | env: |
30 | 48 | FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} |
31 | 49 | FIREBASE_PROJECT: name-of-the-project |
32 | | - TARGET_BRANCH: main |
33 | 50 | ``` |
0 commit comments