Skip to content

Deploy Index to S3

Deploy Index to S3 #42

Workflow file for this run

name: Deploy Index to S3
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8 ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install requirements
run: |
python3 -m pip install -r requirements.txt
sudo snap install yq
- name: Build website
run: |
mkdir ./build
mkdir ./build/docs
mkdir ./build/docs/assets
cp ./mkdocs.yml ./build/mkdocs.yml
cp -r ./assets/images ./build/docs/assets/images
cp -r ./assets/css ./build/docs/assets/css
site_name="Diskover Documentation" yq e '.site_name = env(site_name)' -i ./build/mkdocs.yml
cp ./assets/pages/header.md ./build/docs/index.md
cat ./assets/pages/index.md >> ./build/docs/index.md
echo "Copying images"
cp -r ./source_files/images ./build/docs/images
cd ./build
python3 -m mkdocs build
rm -f ./site/404.html
- name: S3 sync
run: |
aws s3 sync --follow-symlinks ./build/site s3://$AWS_S3_BUCKET
aws s3 cp ./assets/pages/404.html s3://$AWS_S3_BUCKET/404.html
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*" >/dev/null 2>&1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_REGION: 'us-east-1'
DISTRIBUTION_ID: ${{ secrets.DISTRIBUTION_ID }}