Skip to content

Commit e866cb3

Browse files
Deploy to dev on commit and prod on release
- Each commit deploys to dev - Each release deploys to prod
1 parent c97052e commit e866cb3

5 files changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/main.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ name: Infrastructure Deployment
33
# Controls when the action will run. Triggers the workflow on push or pull request
44
# events but only for the main branch
55
on:
6+
release:
7+
types: [released]
68
push:
7-
branches: [main, dev]
9+
branches: [main]
810
paths-ignore:
911
- "**/README.md"
1012
- "**/readme.md"
@@ -17,9 +19,9 @@ concurrency:
1719

1820
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1921
jobs:
20-
# This workflow contains a single job called "build"
2122
build:
22-
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }}
23+
runs-on: ubuntu-20.04
24+
environment: ${{ github.event_name == 'release' && 'Production' || 'Development' }}
2325
env:
2426
MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}
2527
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
@@ -34,14 +36,20 @@ jobs:
3436
GIT_REPOSITORY_URL: https://github.com/neu-dsg/dailp-encoding
3537
OAUTH_TOKEN: ${{ secrets.OAUTH_TOKEN }}
3638
RUST_LOG: info
37-
TF_STAGE: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
38-
# The type of runner that the job will run on
39-
runs-on: ubuntu-latest
39+
TF_STAGE: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
4040

4141
# Steps represent a sequence of tasks that will be executed as part of the job
4242
steps:
4343
- name: Checkout code
4444
uses: actions/checkout@v2
45+
with:
46+
fetch-depth: 0
47+
- name: Push to release branch
48+
if: ${{ github.event_name == 'release' }}
49+
uses: ad-m/github-push-action@master
50+
with:
51+
branch: release
52+
force: true
4553
- name: Configure AWS credentials
4654
uses: aws-actions/configure-aws-credentials@v1
4755
with:

.github/workflows/migrate-data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
jobs:
55
build:
6-
runs-on: ubuntu-latest
6+
runs-on: ubuntu-20.04
77
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }}
88
env:
99
MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}

.github/workflows/publish-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
jobs:
55
publish:
6-
runs-on: ubuntu-latest
6+
runs-on: ubuntu-20.04
77
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }}
88
env:
99
MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}

.github/workflows/terraform-plan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "flake.lock"
1010
jobs:
1111
plan:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-20.04
1313
environment: ${{ github.base_ref == 'main' && 'Production' || 'Development' }}
1414
env:
1515
MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}

terraform/website.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ with builtins; {
9292
};
9393

9494
aws_amplify_branch = let
95-
branchName = if config.setup.stage == "dev" then "dev" else "main";
95+
branchName = if config.setup.stage == "dev" then "main" else "release";
9696
stageName =
9797
if config.setup.stage == "dev" then "DEVELOPMENT" else "PRODUCTION";
9898
in {

0 commit comments

Comments
 (0)