2022-04-26 18:32:52 +00:00
|
|
|
name: 📦 Deploy Website
|
|
|
|
|
2022-04-01 19:29:18 +00:00
|
|
|
on:
|
2022-04-14 15:09:08 +00:00
|
|
|
workflow_dispatch:
|
2022-04-12 03:10:10 +00:00
|
|
|
release:
|
|
|
|
types: [published]
|
2022-04-01 19:29:18 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
PYTHON_VERSION: 3.x
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: Build website
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
2022-04-21 19:25:01 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: '0'
|
2022-04-29 15:21:37 +00:00
|
|
|
ref: ${{github.event.pull_request.head.ref}}
|
|
|
|
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
|
|
ssh-key: ${{ secrets.ACTIONS_SSH_KEY }}
|
|
|
|
submodules: 'true'
|
2022-04-01 19:29:18 +00:00
|
|
|
|
|
|
|
- name: Set up Python runtime
|
2022-06-09 04:13:39 +00:00
|
|
|
uses: actions/setup-python@v4
|
2022-04-01 19:29:18 +00:00
|
|
|
with:
|
2022-04-29 15:21:37 +00:00
|
|
|
python-version: '3.7'
|
2022-04-01 19:29:18 +00:00
|
|
|
|
|
|
|
- name: Cache files
|
2022-07-14 04:13:10 +00:00
|
|
|
uses: actions/cache@v3.0.5
|
2022-04-01 19:29:18 +00:00
|
|
|
with:
|
|
|
|
key: ${{ github.ref }}
|
|
|
|
path: .cache
|
|
|
|
|
|
|
|
- name: Install Python dependencies
|
|
|
|
run: |
|
2022-04-29 15:21:37 +00:00
|
|
|
pip install pipenv
|
|
|
|
pipenv install
|
2022-04-01 19:29:18 +00:00
|
|
|
|
|
|
|
- name: Build website
|
2022-08-07 02:23:48 +00:00
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2022-04-01 19:29:18 +00:00
|
|
|
run: |
|
2022-04-29 15:21:37 +00:00
|
|
|
pipenv run mkdocs build
|
2022-04-01 19:29:18 +00:00
|
|
|
mv .well-known site/
|
|
|
|
tar cvf site.tar site
|
2022-04-29 15:21:37 +00:00
|
|
|
pipenv run mkdocs --version
|
2022-04-01 19:29:18 +00:00
|
|
|
|
|
|
|
- name: Package website
|
2022-04-11 04:14:26 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-04-01 19:29:18 +00:00
|
|
|
with:
|
|
|
|
name: generated-site
|
|
|
|
path: site.tar
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
name: Rsync Deploy
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment: production
|
|
|
|
needs: build
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download generated Jekyll site
|
2022-04-11 04:14:22 +00:00
|
|
|
uses: actions/download-artifact@v3
|
2022-04-01 19:29:18 +00:00
|
|
|
with:
|
|
|
|
name: generated-site
|
|
|
|
- run: tar xvf site.tar
|
|
|
|
- name: Copy built site to production
|
|
|
|
run: |
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
|
|
|
|
chmod 700 ~/.ssh/id_rsa
|
|
|
|
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
|
|
|
|
rsync -azP --delete site/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_PATH }}
|