Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
name: Deploy Dev
name: Deploy to dev Heroku

on:
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP: dev-metaculus-web

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEV_SERVER_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

- name: Run deployment script on dev server
run: |
ssh -o StrictHostKeyChecking=no ubuntu@107.20.216.39 << 'EOF'
bash -il << 'ENDBASH'
echo "Starting interactive shell"
chmod +x /home/ubuntu/rewrite/deploy.sh
/home/ubuntu/rewrite/deploy.sh > /home/ubuntu/deploy.log 2>&1
echo "Finished executing commands"
exit
ENDBASH
EOF
env:
DEV_SERVER_SSH_KEY: ${{ secrets.DEV_SERVER_SSH_KEY }}
- name: Checkout code
uses: actions/checkout@v4
- name: Build and deploy to Heroku
run: |
heroku container:login # uses the HEROKU_API_KEY
docker buildx build --cache-to=type=gha --cache-from type=gha . # used only for caching
./scripts/deploy_to_heroku.sh
8 changes: 7 additions & 1 deletion metaculus_web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@
FAB_CREDITS_OPENAI_API_KEY = os.environ.get("FAB_CREDITS_OPENAI_API_KEY")


ALLOWED_HOSTS = [".metaculus.com", "localhost", "127.0.0.1"]
ALLOWED_HOSTS = [
".metaculus.com",
"localhost",
"127.0.0.1",
"dev-metaculus-web-023b332df454.herokuapp.com/", #remove after we have a DNS entry for dev environment
]

CSRF_TRUSTED_ORIGINS = [FRONTEND_BASE_URL]
INTERNAL_IPS = ["127.0.0.1"]

Expand Down
19 changes: 11 additions & 8 deletions scripts/deploy_to_heroku.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#! /bin/bash
set -x

[ -z "$HEROKU_APP" ] && { echo "Error: HEROKU_APP env varible is not set."; exit 1; }

# Push container
heroku container:push release --arg ENTRY_SCRIPT_ARG="scripts/prod/release.sh"
heroku container:push web --arg ENTRY_SCRIPT_ARG="scripts/prod/startapp.sh"
heroku container:push dramatiq_worker --arg ENTRY_SCRIPT_ARG="scripts/prod/run_dramatiq.sh"
heroku container:push django_cron --arg ENTRY_SCRIPT_ARG="scripts/prod/django_cron.sh"
heroku container:push release --arg ENTRY_SCRIPT_ARG="scripts/prod/release.sh" -a $HEROKU_APP
heroku container:push web --arg ENTRY_SCRIPT_ARG="scripts/prod/startapp.sh" -a $HEROKU_APP
heroku container:push dramatiq_worker --arg ENTRY_SCRIPT_ARG="scripts/prod/run_dramatiq.sh" -a $HEROKU_APP
heroku container:push django_cron --arg ENTRY_SCRIPT_ARG="scripts/prod/django_cron.sh" -a $HEROKU_APP

# Release them
heroku container:release release
heroku container:release web
heroku container:release dramatiq_worker
heroku container:release django_cron
heroku container:release release -a $HEROKU_APP
heroku container:release web -a $HEROKU_APP
heroku container:release dramatiq_worker -a $HEROKU_APP
heroku container:release django_cron -a $HEROKU_APP