Configure HTTP headers through Firebase hosting for caching & security #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
name: Build and Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Ruby 3.0 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.0 | |
- name: Cache bundler gems | |
id: cache-bundler | |
uses: actions/cache@v4 | |
with: | |
path: .bundler | |
key: ${{ runner.os }}-gems-v2-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems-v2- | |
- name: Install Bundler & Gems | |
if: steps.cache-bundler.outputs.cache-hit != 'true' | |
run: | | |
gem install bundler | |
bundle config set --local without 'development' | |
bundle config set --local path .bundler | |
bundle install --jobs "$(nproc)" | |
- name: Install Bundler only | |
if: steps.cache-bundler.outputs.cache-hit == 'true' | |
run: | | |
gem install bundler | |
bundle config set --local without 'development' | |
bundle config set --local path .bundler | |
- name: Cache nanoc | |
id: cache-nanoc | |
uses: actions/cache@v4 | |
with: | |
path: output | |
key: ${{ runner.os }}-nanoc-prod-v2-${{ hashFiles('content/**', 'Rules', 'nanoc.yaml', 'lib/**', 'layouts/**') }} | |
restore-keys: | | |
${{ runner.os }}-nanoc-prod-v2- | |
- name: Build | |
id: build | |
run: | | |
export LANG=en_US.UTF-8 | |
export LANGUAGE=en_US:en | |
export LC_ALL=en_US.UTF-8 | |
bundle exec nanoc compile --env=prod -V | |
- name: Setup Node | |
if: steps.build.outputs.need_deploy == 0 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '21' | |
cache: 'npm' | |
- name: Deploy prod | |
env: | |
GIT_SHA: ${{ github.sha }} | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
run: | | |
npm ci | |
node_modules/.bin/firebase deploy --only hosting -m "GitHub Actions@${GIT_SHA::8}" --token "$FIREBASE_TOKEN" --non-interactive |