Skip to content

Commit

Permalink
Add notes on deployment to staging and trigger deploy-opentofu.yml
Browse files Browse the repository at this point in the history
…if it is modified
  • Loading branch information
smokestacklightnin committed Nov 1, 2024
1 parent b541dc7 commit 9f8cc66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-opentofu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- '!main'
paths:
- 'web/deploy/terraform/**'
- '.github/workflows/deploy-opentofu.yml'
workflow_dispatch:
inputs:
development-environment:
Expand All @@ -29,6 +30,8 @@ on:
- closed
paths:
- 'web/deploy/terraform/**'
- '.github/workflows/deploy-opentofu.yml'

env:
working_directory_parent: ./web/deploy/terraform
TF_VAR_AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
Expand Down
8 changes: 8 additions & 0 deletions web/deploy/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,12 @@ $ tofu apply

In general, once everything is configured and resources are up, the only human interaction necessary is during [deployment to production](#deployment-to-production).

### Deployment to Staging

When pull requests are merged to main, up to two main workflows are run: [`deploy-docker.yml`](../../../.github/workflows/deploy-docker.yml) and [`deploy-opentofu.yml`](../../../.github/workflows/deploy-opentofu.yml).

If none of the files in a pull request are included in `web/deploy/terraform` or `.github/workflows/deploy-opentofu.yml`, then only `deploy-docker.yml` will be run and the Docker image on the staging EC2 instance will be pushed and rerun.

If any of the files in a pull request is included in `web/deploy/terraform` or `.github/workflows/deploy-opentofu.yml`, then both `deploy-docker.yml` and `deploy-opentofu.yml` will be run. In this case, however, `deploy-docker.yml` will see that paths dealing with OpenTofu were modified and terminate early and successfully without doing anything. At the same time, `deploy-opentofu.yml` will run and redeploy both shared and staging resources to the staging EC2 instance. After running all OpenTofu actions successfully, `deploy-opentofu.yml` will run `deploy-docker.yml` as a child workflow via the [`workflow_call`](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_call) trigger. This way, the potent parts of `deploy-docker.yml`, i.e. the parts that actually build and deploy images, is only run once per merged pull request.

### Deployment to Production

0 comments on commit 9f8cc66

Please sign in to comment.