Skip to content

Instantly share code, notes, and snippets.

@siriwatknp
Last active July 5, 2021 13:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siriwatknp/bd318485d5b0c12049be258997ad0093 to your computer and use it in GitHub Desktop.
Save siriwatknp/bd318485d5b0c12049be258997ad0093 to your computer and use it in GitHub Desktop.
Github actions for Gatsby + firebase hosting
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: yarn
- name: Build
run: yarn build
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: public
path: public
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: public
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
@etnichols
Copy link

Quite helpful, thanks for sharing!

@WyFryMU
Copy link

WyFryMU commented Mar 22, 2021

This works like a charm, except I had an error with not being able to find the public folder when in the deploying stage, so I had to add "path: public" to the deploy stage too to fix that.

@jainam333
Copy link

run: yarn gatsby build

path: public

@jainam333
Copy link

name: Build and Deploy
on:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: yarn
- name: Build
run: yarn gatsby build
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: public
path: public
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: public
path: public
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

@aljorgevi
Copy link

Hi guys, I have a question. How would be with an extra env key? i tried likes this:

env: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} CONTENFUL_API_KEY: ${{ secrets.CONTENFUL_API_KEY }}.

And I just couldn't make it work...
I got this message: "accessToken" is required github actions dev ...

Of course, I added it to "secrets". Thanks.

@BorisBosnar
Copy link

Hey guys,
I am using reCAPTCHA v3 on my Gatsby website and need to pass the API key to the component. For this I wanted to use the Secrets from Github Actions but where do I have to position the env variable in the action.yml so that I can retrieve it in Gatsby with process.env.RECAPTCHA_API_KEY?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment