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: Build and update README, deploy to Heroku, and post to Slack | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v2 | |
# We need full history to introspect created/updated: | |
with: | |
fetch-depth: 0 | |
path: main | |
- name: Checkout til-db | |
uses: actions/checkout@v2 | |
with: | |
repository: jthodge/til-db | |
path: til-db | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_PUSH }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- uses: actions/cache@v3 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node- | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r main/requirements.txt | |
- name: Install npm dependencies | |
run: sudo npm install -g puppeteer-cli --unsafe-perm=true | |
- name: Download previous database unless REBUILD in commit message | |
if: |- | |
!contains(github.event.head_commit.message, 'REBUILD') | |
run: curl --fail -o main/til.db https://raw.githubusercontent.com/jthodge/til-db/main/til.db | |
continue-on-error: true | |
- name: Build database | |
env: | |
SCREENSHOT_HOST: ${{ secrets.SCREENSHOT_HOST }} | |
SCREENSHOT_KEY: ${{ secrets.SCREENSHOT_KEY }} | |
run: |- | |
cd main | |
python build_db.py | |
# - name: Soundness check | |
# run: |- | |
# cd main | |
# datasette . --get / | grep "Taylor Hodge: TIL" | |
# - name: Generate missing screenshots | |
# run: |- | |
# cd main | |
# python generate_screenshots.py | |
- name: Update README | |
run: |- | |
cd main | |
python update_readme.py --rewrite | |
cat README.md | |
- name: Commit and push if README changed | |
run: |- | |
cd main | |
git diff | |
git config --global user.email "[email protected]" | |
git config --global user.name "jthodge" | |
git diff --quiet || (git add README.md && git commit -m "Updated README") | |
git push | |
- name: Save til.db to jthodge/til-db | |
run: |- | |
cd til-db | |
cp ../main/til.db . | |
git add til.db | |
git commit --amend --no-edit | |
git push --force | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Deploy Datasette using Heroku | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
run: |- | |
cd main | |
heroku plugins:install heroku-builds | |
datasette publish heroku til.db \ | |
--branch main \ | |
--name til-taylorhodge \ | |
--metadata metadata.yaml \ | |
--install datasette-template-sql \ | |
--install "datasette-atom>=0.7" \ | |
--install datasette-json-html \ | |
--install beautifulsoup4 \ | |
--install datasette-debug-asgi \ | |
--install "datasette-graphql>=0.12" \ | |
--install datasette-media \ | |
--plugins-dir plugins \ | |
--template-dir templates | |
# - name: Post Slack Notification | |
# uses: rtCamp/action-slack-notify@master | |
# env: | |
# SLACK_ICON: https://user-images.githubusercontent.com/17075617/149437305-53baad9e-9800-4fe4-a3bf-13bd28d98f8b.png | |
# SLACK_USERNAME: taylor | |
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |