Skip to content

Commit

Permalink
Merge pull request #8 from lowply/default-branch
Browse files Browse the repository at this point in the history
Introduce TARGET_BRANCH env var
  • Loading branch information
lowply authored Jun 14, 2020
2 parents 30455d5 + ce70600 commit 14a944b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A GitHub Action to deploy to Firebase Hosting

- This action only deploys the `master` branch
- You can choose a specific branch to allow deployment by using the `TARGET_BRANCH` env var (`master` if not specified).
- Make sure you have the `firebase.json` file in the repository
- 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
- Set the project name in the `FIREBASE_PROJECT` env var
Expand All @@ -14,7 +14,7 @@ name: Build and Deploy
on:
push:
branches:
- master
- main
jobs:
main:
name: Build and Deploy
Expand All @@ -25,8 +25,9 @@ jobs:
- name: Build Hugo
uses: lowply/[email protected]
- name: Deploy to Firebase
uses: lowply/[email protected].2
uses: lowply/[email protected].3
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: name-of-the-project
TARGET_BRANCH: main
```
10 changes: 7 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ if [ -z "${FIREBASE_PROJECT}" ]; then
exit 1
fi

if [ "${GITHUB_REF}" != "refs/heads/master" ]; then
echo "Branch: ${GITHUB_REF}"
echo "Aborting non-master branch deployment"
if [ -z "${TARGET_BRANCH}" ]; then
TARGET_BRANCH="master"
fi

if [ "${GITHUB_REF}" != "refs/heads/${TARGET_BRANCH}" ]; then
echo "Current branch: ${GITHUB_REF}"
echo "Aborting deployment"
exit 1
fi

Expand Down

0 comments on commit 14a944b

Please sign in to comment.