-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (56 loc) · 1.9 KB
/
6-scheduled-production-worker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: 6 - Schedule a Production Worker
on:
workflow_dispatch:
schedule:
- cron: '0 1,12 * * *'
- cron: '0 4 1 * *'
jobs:
test:
runs-on: ubuntu-latest
env:
DJANGO_DEBUG: 0
STRIPE_TEST_OVERRIDE: 1
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }}
NEON_PROD_BRANCH: 'main'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.18"
- name: Install Neon CLI
run: |
npm install -g neonctl
- name: Database URL Env Var for new GitHub Actions branch
run: |
MY_NEON_CONN_STRING=$(neonctl connection-string --branch "${{ env.NEON_PROD_BRANCH }}" --project-id "${{ env.NEON_PROJECT_ID }}")
echo "DATABASE_URL=$MY_NEON_CONN_STRING" >> $GITHUB_ENV
- name: Setup django secret key
run: |
MY_GEN_KEY=$(openssl rand -base64 32)
echo "DJANGO_SECRET_KEY=$MY_GEN_KEY" >> $GITHUB_ENV
- name: Install Requirements
run: |
python -m pip install pip --upgrade
python -m pip install -r requirements.txt
- name: Django Migrate Database
working-directory: ./src
run: |
python manage.py migrate
- name: Django Users Sync Stripe Subscriptions
if: github.event.schedule != '0 4 1 * *'
working-directory: ./src
run: |
python manage.py sync_user_subs --days-start 0 --days-end 1
- name: Django Users Clear Dangling Stripe Subscriptions
if: github.event.schedule == '0 4 1 * *'
working-directory: ./src
run: |
python manage.py sync_user_subs --clear-dangling