Skip to content
Open
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
41 changes: 37 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
parameters:
ssh:
type: string
default: "ssh -o StrictHostKeyChecking=no $SCOPULI_RUNNER_SSH_USER@$SCOPULI_RUNNER_SSH_HOST SCOPULI_RUNNER_DIR=$SCOPULI_RUNNER_DIR"
default: "ssh -o StrictHostKeyChecking=no $JOBRUNNER_SSH_USER@$JOBRUNNER_SSH_HOST JOBRUNNER_DIR=$JOBRUNNER_DIR"
scp:
type: string
default: "scp -o StrictHostKeyChecking=no"
Expand All @@ -27,14 +27,17 @@ jobs:
name: Add SSH forwarding
command: |
eval `ssh-agent -s` && ssh-add -k
- run:
name: Print environment vars
command: printenv
- run:
name: Pull Latest Head of Main
command: |
<< parameters.ssh >> "cd $SCOPULI_RUNNER_DIR/scopuli && git checkout $SCOPULI_ENV && git pull"
<< parameters.ssh >> "cd $JOBRUNNER_DIR/jobrunner && git checkout ashannon/jobrunner/dispatch_jobs && git pull"
- run:
name: Set up server's environment variables
description: |
Sets up the server's environmnet variables. Avoid using ssh to source the variables in this step.
Sets up the server's environment variables. Avoid using ssh to source the variables in this step.
It can cause an exit 255 since the scp command precedes it.
command: |
echo "export SCOPULI_PROD_PG_HOST=${SCOPULI_PROD_PG_HOST}" >> .env
Expand All @@ -47,7 +50,24 @@ jobs:
- run:
name: Update the cron schedule
command: |
<< parameters.ssh >> "bash $SCOPULI_RUNNER_DIR/scopuli/scheduler/schedule.sh"
<< parameters.ssh >> "bash $JOBRUNNER_DIR/jobrunner/schedule.sh"
- run:
name: List crontab
command: |
<< parameters.ssh >> "crontab -l"
- run:
name: Check crontab
command: |
<< parameters.ssh >> "bash $JOBRUNNER_DIR/jobrunner/check_crontab.sh"
test:
docker:
- image: cimg/base:2023.06
steps:
- run:
name: Test push to remote main trigger
command: |
echo "new commit to main"

workflows:
deploy-to-prod:
jobs:
Expand All @@ -57,3 +77,16 @@ workflows:
filters:
branches:
only: main
push-to-remote-main:
jobs:
- test:
filters:
branches:
only: ashannon/jobrunner/dispatch_jobs
- deploy:
context:
- aethersphere-prod
filters:
branches:
only: ashannon/jobrunner/dispatch_jobs

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scopuli"]
path = scopuli
url = git@github.com:tm41m/scopuli.git
11 changes: 11 additions & 0 deletions check_crontab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

target_job="0 0 */2 * * docker run --env-file /home/circleci/.env --network=host --mount type=bind,source=/home/circleci/jobrunner/scopuli/ganymede/,target=/usr/app --mount type=bind,source=/home/circleci/jobrunner/scopuli/,target=/root/.dbt/ ghcr.io/dbt-labs/dbt-postgres:1.5.2 run --target prod"

crontab_content=$(crontab -l)

if [[ $crontab_content == *"$target_job"* ]]; then
echo "dbt job has been scheduled"
else
echo "error, dbt job has not been properly scheduled"
fi
3 changes: 1 addition & 2 deletions schedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
crontab -r

# dbt run
dbt_run="0 0 */2 * * docker run --env-file /home/circleci/.env --network=host --mount type=bind,source=/home/circleci/scopuli/ganymede/,target=/usr/app --mount type=bind,source=/home/circleci/scopuli/,target=/root/.dbt/ ghcr.io/dbt-labs/dbt-postgres:1.5.2 run --target prod"
cmd_1="0 0 */2 * * pwd"
dbt_run="0 0 */2 * * docker run --env-file /home/circleci/.env --network=host --mount type=bind,source=/home/circleci/jobrunner/scopuli/ganymede/,target=/usr/app --mount type=bind,source=/home/circleci/jobrunner/scopuli/,target=/root/.dbt/ ghcr.io/dbt-labs/dbt-postgres:1.5.2 run --target prod"

# Create a temporary file to store the cron job entries
temp_file=$(mktemp)
Expand Down
1 change: 1 addition & 0 deletions scopuli
Submodule scopuli added at 901a2a