Skip to content

Commit 2d5ea96

Browse files
authored
Merge pull request #16 from lowply/remove-branch-restriction
Remove branch restriction
2 parents 9aa934b + ac25115 commit 2d5ea96

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

README.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,50 @@
11
# Deploy to Firebase
22

3-
A GitHub Action to deploy to Firebase Hosting
3+
A GitHub Action to deploy to Firebase Hosting.
44

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
99

10-
Example workflow
10+
## Workflow examples
11+
12+
Deploy the `main` branch when a commit is pushed to it:
1113

1214
```
13-
name: Build and Deploy
15+
name: Deploy the main branch
1416
on:
1517
push:
1618
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*
1840
jobs:
1941
main:
20-
name: Build and Deploy
42+
name: Deploy to Firebase
2143
runs-on: ubuntu-latest
2244
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
2947
env:
3048
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
3149
FIREBASE_PROJECT: name-of-the-project
32-
TARGET_BRANCH: main
3350
```

entrypoint.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
if [ -z "${FIREBASE_TOKEN}" ]; then
44
echo "FIREBASE_TOKEN is missing"
@@ -10,17 +10,7 @@ if [ -z "${FIREBASE_PROJECT}" ]; then
1010
exit 1
1111
fi
1212

13-
if [ -z "${TARGET_BRANCH}" ]; then
14-
TARGET_BRANCH="master"
15-
fi
16-
17-
if [ "${GITHUB_REF}" != "refs/heads/${TARGET_BRANCH}" ]; then
18-
echo "Current branch: ${GITHUB_REF}"
19-
echo "Aborting deployment"
20-
exit 1
21-
fi
22-
2313
firebase deploy \
24-
-m "${GITHUB_SHA}" \
14+
-m "${GITHUB_REF} (${GITHUB_SHA})" \
2515
--project ${FIREBASE_PROJECT} \
2616
--only hosting

0 commit comments

Comments
 (0)