Skip to content

Commit

Permalink
Merge pull request #1 from lowply/v2
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
lowply authored Aug 20, 2019
2 parents dc9d5d3 + d176a36 commit b9abeaa
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 35 deletions.
14 changes: 2 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
FROM node:10-slim

LABEL "com.github.actions.name"="Deploy to Firebase"
LABEL "com.github.actions.description"="Deploy to Firebase"
LABEL "com.github.actions.icon"="cloud"
LABEL "com.github.actions.color"="red"
LABEL "repository"="https://github.com/lowply/deploy-firebase"
LABEL "homepage"="https://github.com/lowply"
LABEL "maintainer"="Sho Mizutani <lowply@github.com>"

RUN npm install -g firebase-tools

ADD entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
COPY entrypoint.sh /usr/local/bin
ENTRYPOINT ["entrypoint.sh"]
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
A GitHub Action to deploy to Firebase Hosting

- This action only deploys the `master` branch
- Make sure you have the `.firebaserc` and `firebase.json` files in the repository
- Get the Firebase token by running `firebase login:ci` and [store it](https://developer.github.com/actions/creating-workflows/storing-secrets/) into the `FIREBASE_TOKEN` secret in the workflow
- 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/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) as the `FIREBASE_TOKEN` secret
- Set the project name in the `FIREBASE_PROJECT` env var

Example workflow

```
workflow "Deploy" {
on = "push"
resolves = ["Deploy to Firebase"]
}
action "Build Hugo" {
uses = "lowply/build-hugo@master"
runs = "hugo"
}
action "Deploy to Firebase" {
uses = "lowply/deploy-firebase@master"
needs = ["Build Hugo"]
secrets = ["FIREBASE_TOKEN"]
}
```
name: Build and Deploy
on:
push:
branches:
- master
jobs:
main:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
- name: Build Hugo
uses: lowply/build-hugo@v0.0.2
- name: Deploy to Firebase
uses: lowply/deploy-firebase@v0.0.2
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: name-of-the-project
```
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Deploy to Firebase'
author: 'Sho Mizutani <lowply@github.com>'
description: 'A GitHub Action to deploy to Firebase Hosting'
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'cloud'
color: 'red'
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker build -t lowply/deploy-firebase .
13 changes: 8 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/sh

if [ -z "$FIREBASE_TOKEN" ]; then
if [ -z "${FIREBASE_TOKEN}" ]; then
echo "FIREBASE_TOKEN is missing"
exit 1
fi

if [ ! -f ".firebaserc" ]; then
echo ".firebaserc is missing"
if [ -z "${FIREBASE_PROJECT}" ]; then
echo "FIREBASE_PROJECT is missing"
exit 1
fi

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

firebase deploy --only hosting
firebase deploy \
-m "${GITHUB_SHA}" \
--project ${FIREBASE_PROJECT} \
--only hosting

0 comments on commit b9abeaa

Please sign in to comment.