Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2f139eb
Initial work on removing old deployment files and setting up new config
GUI Apr 21, 2026
8250944
Fixes for initial keys/settings revamp work.
GUI Apr 21, 2026
226596d
Trying to setup new GitHub Actions based deployment approach.
GUI Apr 23, 2026
cc173d6
Try workaround for extracting non-sensitive secrets.
GUI Apr 23, 2026
edcf190
Try different approach to extracting non-sensitive secrets.
GUI Apr 23, 2026
4726ab9
Fix staging config rendering.
GUI Apr 23, 2026
35135ab
Fix image name during build
GUI Apr 23, 2026
1b27d5e
Update vault kubeconfig paths for reopt api cluster.
GUI Apr 23, 2026
2218e0f
Improve docker cacheablity of build process.
GUI Apr 23, 2026
29f52d6
Fix julia deployment using incorrect container.
GUI Apr 23, 2026
5c53ff5
Fix service URLs
GUI Apr 23, 2026
f379f43
Additional dockerignore rules for better build caching.
GUI Apr 23, 2026
2e5dbcc
Fix missing URL hosts for deployments.
GUI Apr 23, 2026
111b9a1
Use new settings to deduplicate some things.
GUI Apr 23, 2026
a5c306d
Increase staging django memory limit.
GUI Apr 23, 2026
e355daa
Tweaks to use stable versions of dependencies we've merged updates to.
GUI Apr 23, 2026
b3095ed
Provide .env example file and update instructions
GUI Apr 23, 2026
4e231cc
Setup restart celery/julia restart job in GitHub Actions.
GUI Apr 23, 2026
62a3d91
Merge remote-tracking branch 'origin/master' into deploy-updates
GUI May 27, 2026
86a8e5d
Test PostgreSQL v18 deployment
GUI May 27, 2026
2beae8d
Use our db-syncer Ruby gem for providing db dump/restore tasks.
GUI May 27, 2026
e64ed5e
Rely on kubernetes secrets in deployed environment.
GUI Jun 3, 2026
589b684
Add secret value so db-syncer process can spin up.
GUI Jun 3, 2026
c4c24de
Merge remote-tracking branch 'origin/master' into deploy-updates
GUI Jun 4, 2026
9e597e3
Don't run on every push.
GUI Jun 4, 2026
6b55483
Merge remote-tracking branch 'origin/deploy-updates' into pg-v18
GUI Jun 4, 2026
438707d
Try to fix restores during staging deploys.
GUI Jun 4, 2026
8e48a6f
Try to fix permissions used during restores.
GUI Jun 4, 2026
07a2bb8
Include django_migrations in database dumps.
GUI Jun 4, 2026
9a8a8d8
Fix permissions on restored tables.
GUI Jun 4, 2026
54def5f
Shift db-syncer to separate docker compose profile
GUI Jun 4, 2026
b51e8a7
Have tests use standard database credentials from environment variables
GUI Jun 4, 2026
8fd53c2
Fix to create database schema for test environment.
GUI Jun 4, 2026
513c114
Fix for environments where user running migrations lacks CREATE perms
GUI Jul 7, 2026
f125456
Fix database restore not restoring to same database used by API.
GUI Jul 15, 2026
43f4cce
Preparing for production deploy.
GUI Jul 20, 2026
ecdea05
Merge pull request #720 from NatLabRockies/pg-v18
GUI Jul 20, 2026
fed227f
Perform dry-run deploys to see how new deployments will work in main.
GUI Jul 20, 2026
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
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.git
.git*
env/
*.pyc
*.rdb
Expand All @@ -14,3 +14,10 @@ Jenkinsfile
werf.yaml
**/*.dylib
**/*.dll
Dockerfile*
.dockerignore
/config/deploy

/db-syncer/tmp
/db-syncer/log
!/db-syncer/.gomplate.yaml
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Get your individual key from here: https://developer.nlr.gov/signup/ and
# replace the DEMO_KEY with that
NLR_API_KEY=DEMO_KEY
6 changes: 0 additions & 6 deletions .github/scripts/decrypt.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .github/scripts/make_keys.py.sh

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/db-sync-dump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: DB Sync Dump

on:
schedule:
- cron: "40 5 * * *" # Every day at 10:40 PM MST / 11:40 PM MDT
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
vault-nonsensitive-secrets:
name: Vault Non-Sensitive Secrets
runs-on: self-hosted
outputs:
nonsensitive-secrets: ${{ steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets }}
steps:
- name: Import vault nonsensitive secrets
id: vault-nonsensitive-secrets
uses: TADA/vault-action/nonsensitive-secrets@v1
with:
template: |
{{ with (datasource "vault" "reopt-api/ci/deploy").data }}
{{ $secrets = coll.Merge (coll.Dict
"container_registry" .container_registry
"staging_rancher_project_id" .staging_rancher_project_id
) $secrets }}
{{ end }}
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}

dump:
name: Dump
uses: TADA/deploy-action/.github/workflows/run-job.yml@v2
needs:
- vault-nonsensitive-secrets
with:
job-name: reopt-api-db-sync-dump
job-command: "DB_SYNCER_PERFORM_UPLOAD=true rails db:data:dump --trace"
deploy-env: production
render-config-command: "DB_OWNER_AUTH=true DB_SYNCER=true RENDER_JOB=run-job RUN_JOB_CONTAINER_IMAGE=db-syncer ./config/deploy/render"
rancher-project-id: ${{ fromJSON(needs.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).staging_rancher_project_id }}
registry: ${{ fromJSON(needs.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).container_registry }}
vault-registry-credentials-path: secret/data/deploy/common/aws-ecr
vault-kubeconfig-path: secret/data/deploy/staging/on-prem-rancher-test-ponderosa-cluster-test-reopt
force-run: true
secrets:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}
125 changes: 125 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Deploy

on:
push:
branches: "**"
pull_request:
types:
- closed
- labeled
- reopened
- unlabeled
workflow_dispatch:
inputs:
db-sync-restore:
description: "Staging Only: Restore this branch's database with a recent snapshot from production."
type: boolean

concurrency:
# Concurrency group is more complicated in this case because:
# 1. This gets triggered by both `push` and `pull_request` label events, so
# both should use the same git head ref (and not `github.ref`, which may
# be different for PRs).
# 2. Our own deploy process may trigger an `unlabeled` event for removing the
# db-restore label, so separate that so that doesn't cause the previous
# deploy that was finishing up to be canceled.
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}${{ github.event.action == 'unlabeled' && github.event.label.name == 'deploy-db-restore' && '-removing-ephemeral-label' || '' }}
cancel-in-progress: true

jobs:
deploy-metadata:
name: Deploy Metadata
runs-on: self-hosted
outputs:
staging-perform-deploy: ${{ steps.staging-metadata.outputs.perform-deploy }}
staging-perform-undeploy: ${{ steps.staging-metadata.outputs.perform-undeploy }}
staging-metadata: ${{ toJSON(steps.staging-metadata.outputs) }}
production-perform-deploy: ${{ steps.production-metadata.outputs.perform-deploy }}
production-metadata: ${{ toJSON(steps.production-metadata.outputs) }}
steps:
- name: Import vault nonsensitive secrets
id: vault-nonsensitive-secrets
uses: TADA/vault-action/nonsensitive-secrets@v1
with:
template: |
{{ with (datasource "vault" "reopt-api/ci/deploy").data }}
{{ $secrets = coll.Merge (coll.Dict
"container_registry" .container_registry
"production_rancher_project_id" .production_rancher_project_id
"production_url_host" .production_url_host
"staging_rancher_project_id" .staging_rancher_project_id
"staging_url_host_base" .staging_url_host_base
) $secrets }}
{{ end }}
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}

- name: Staging Metadata
id: staging-metadata
uses: TADA/deploy-action/metadata@v2
with:
deploy-env: staging
app-name: reopt-api
rancher-project-id: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).staging_rancher_project_id }}
registry: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).container_registry }}
branch-url-host-base: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).staging_url_host_base }}
branch-db-name-base: reopt_api_staging

- name: Production Metadata
id: production-metadata
uses: TADA/deploy-action/metadata@v2
with:
deploy-env: production
app-name: reopt-api
rancher-project-id: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).production_rancher_project_id }}
registry: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).container_registry }}
branch-url-host-base: ${{ fromJSON(steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).production_url_host }}

undeploy-staging:
name: Undeploy Staging
needs:
- deploy-metadata
if: ${{ needs.deploy-metadata.outputs.staging-perform-undeploy == 'true' }}
uses: TADA/deploy-action/.github/workflows/undeploy-branch.yml@v2
with:
metadata: ${{ needs.deploy-metadata.outputs.staging-metadata }}
vault-kubeconfig-path: secret/data/deploy/staging/on-prem-rancher-test-ponderosa-cluster-test-reopt
vault-db-superuser-path: secret/data/reopt-db/staging/db-superuser
secrets:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}

deploy-staging:
name: Deploy Staging
needs:
- deploy-metadata
if: ${{ needs.deploy-metadata.outputs.staging-perform-deploy == 'true' }}
uses: TADA/deploy-action/.github/workflows/deploy.yml@v2
with:
metadata: ${{ needs.deploy-metadata.outputs.staging-metadata }}
vault-registry-credentials-path: secret/data/deploy/common/aws-ecr
vault-kubeconfig-path: secret/data/deploy/staging/on-prem-rancher-test-ponderosa-cluster-test-reopt
# FIXME: Temporarily disable deploys and perform a dry run so we can see
# how all this would get rolled out once we merge with `main`.
dry-run: true
secrets:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}

deploy-production:
name: Deploy Production
needs:
- deploy-metadata
- deploy-staging
if: ${{ needs.deploy-metadata.outputs.production-perform-deploy == 'true' }}
uses: TADA/deploy-action/.github/workflows/deploy.yml@v2
with:
metadata: ${{ needs.deploy-metadata.outputs.production-metadata }}
vault-registry-credentials-path: secret/data/deploy/common/aws-ecr
vault-kubeconfig-path: secret/data/deploy/production/on-prem-rancher-ponderosa-cluster-reopt
# FIXME: Temporarily disable deploys and perform a dry run so we can see
# how all this would get rolled out once we merge with `main`.
dry-run: true
secrets:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}
51 changes: 51 additions & 0 deletions .github/workflows/prune-deploy-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Prune Deploy Images

on:
schedule:
- cron: "6 6 * * *" # Every day at 11:06 PM MST / 12:06 AM MDT
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
vault-nonsensitive-secrets:
name: Vault Non-Sensitive Secrets
runs-on: self-hosted
outputs:
nonsensitive-secrets: ${{ steps.vault-nonsensitive-secrets.outputs.nonsensitive-secrets }}
steps:
- name: Import vault nonsensitive secrets
id: vault-nonsensitive-secrets
uses: TADA/vault-action/nonsensitive-secrets@v1
with:
template: |
{{ with (datasource "vault" "reopt-api/ci/deploy").data }}
{{ $secrets = coll.Merge (coll.Dict
"container_registry" .container_registry
"production_rancher_project_id" .production_rancher_project_id
"staging_rancher_project_id" .staging_rancher_project_id
) $secrets }}
{{ end }}
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}

prune-images:
name: Prune Deploy Images
uses: TADA/deploy-action/.github/workflows/prune-deploy-images.yml@v2
needs:
- vault-nonsensitive-secrets
with:
vault-registry-credentials-path: secret/data/deploy/common/aws-ecr
registry: ${{ fromJSON(needs.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).container_registry }}
images: |
tada/reopt-api
clusters: |
- vault-kubeconfig-path: secret/data/deploy/staging/on-prem-rancher-test-ponderosa-cluster-test-reopt
rancher-project-id: ${{ fromJSON(needs.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).staging_rancher_project_id }}
- vault-kubeconfig-path: secret/data/deploy/production/on-prem-rancher-ponderosa-cluster-reopt
rancher-project-id: ${{ fromJSON(needs.vault-nonsensitive-secrets.outputs.nonsensitive-secrets).production_rancher_project_id }}
secrets:
vault-role-id: ${{ secrets.VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.VAULT_SECRET_ID }}
12 changes: 3 additions & 9 deletions .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# - name: Decrypt
# env:
# TRANSCRYPT_PASSWORD: ${{ secrets.TRANSCRYPT_PASSWORD }}
# run: ./.github/scripts/decrypt.sh
- name: Make keys.py
env:
NREL_DEV_API_KEY: ${{ secrets.NREL_DEV_API_KEY }}
run: ./.github/scripts/make_keys.py.sh
- uses: actions/checkout@v5
- name: Build containers
run: docker compose up -d
env:
NLR_API_KEY: ${{ secrets.NREL_DEV_API_KEY }}
- name: Check running containers
run: docker ps -a
- name: Wait for julia_api
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/push_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# - name: Decrypt
# env:
# TRANSCRYPT_PASSWORD: ${{ secrets.TRANSCRYPT_PASSWORD }}
# run: ./.github/scripts/decrypt.sh
- name: Make keys.py
env:
NREL_DEV_API_KEY: ${{ secrets.NREL_DEV_API_KEY }}
run: ./.github/scripts/make_keys.py.sh
- uses: actions/checkout@v5
- name: Build containers
run: docker compose up -d
env:
NLR_API_KEY: ${{ secrets.NREL_DEV_API_KEY }}
- name: Check running containers
run: docker ps -a
- name: Wait for julia_api
Expand Down
Loading