Deploy Hugo with Github actions
This website is hosted by Firebase hosting. This website is configured that when I create a new post and push it to Github, it will be deployed to Firebase hosting automatically. This is my Github actions.
Set yaml file
This file is located in .github/workflows/
name: hugo
on:
push:
branches: []
pull_request:
branches: []
jobs:
build:
name: build hugo projects
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
- name: build hugo pages
run: hugo
deploy:
name: Deploy
if: ${{ github.ref == 'refs/heads/master' }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
- name: build hugo pages
run: hugo
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
Get firebase token for deployment
As you know, to deploy Firebase hosting from Github actions, you must set FIREBASE_TOKEN
in the Github secrets. You can get it by the following command. If you run it, the browser automatically lanches and you can log-in Google.
$ firebase login:ci
Set the FIREBASE_TOKEN to your Github secrets
Go over Settings > Secrets and you can set the FIREBASE_TOKEN there. Then, every push to the master branch will deploy to your website.
comments powered by Disqus