personal-website/.github/workflows/deploy.yml

52 lines
1.5 KiB
YAML

name: Deploy
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.2'
- name: Enable bundler cache
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install deps
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
npm install -g mermaid.cli
- name: Setup deploy options
id: setup
run: |
git config --local user.name "$(git log --format=%an | head -n 1)"
git config --local user.email "$(git log --format=%ae | head -n 1)"
if [[ ${GITHUB_REF} = refs/pull/*/merge ]]; then
echo "::set-output name=SRC_BRANCH::${GITHUB_HEAD_REF}"
echo "::set-output name=NO_PUSH::--no-push"
elif [[ ${GITHUB_REF} = refs/heads/* ]]; then
echo "::set-output name=SRC_BRANCH::${GITHUB_REF#refs/heads/}"
fi
echo "::set-output name=DEPLOY_BRANCH::gh-pages"
- name: Deploy website
run: yes | bin/deploy.sh --verbose ${{ steps.setup.outputs.NO_PUSH }}
--src ${{ steps.setup.outputs.SRC_BRANCH }}
--deploy ${{ steps.setup.outputs.DEPLOY_BRANCH }}