Skip to content

Commit 3cead66

Browse files
authored
fix: pr open for manual deploys (#87)
* fix: pr open for manual deploys * fix: trivy permissions * fix: add resume before deploy * fix: permissions * chore: docs
1 parent ef46f56 commit 3cead66

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.github/workflows/.tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ jobs:
7676
name: Trivy Security Scan
7777
if: ${{ ! github.event.pull_request.draft }}
7878
runs-on: ubuntu-24.04
79+
permissions:
80+
contents: read # This is required for actions/checkout
81+
security-events: write # This is required to upload SARIF results to the Security tab
7982
timeout-minutes: 1
8083
steps:
8184
- uses: actions/checkout@v4

.github/workflows/pr-open.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: PR
22

33
on:
44
pull_request:
5+
56
workflow_dispatch:
67

78
concurrency:
@@ -13,6 +14,7 @@ permissions:
1314
contents: write # This is required for actions/checkout
1415
packages: write
1516
pull-requests: write
17+
security-events: write
1618
env:
1719
AWS_REGION: ca-central-1
1820
jobs:
@@ -41,26 +43,31 @@ jobs:
4143
with:
4244
environment_name: dev
4345
command: plan
44-
tag: ${{ github.event.number || 'latest' }} # this is the tag of the containers to deploy, defaults to test
45-
app_env: ephermal-${{ github.event.number || 'latest' }} # ephermal, prefixed for easy clean up of PR resources in s3 and dynamodb generated by terraform
46+
tag: ${{ github.event.number || 'latest' }}
47+
app_env: ${{ github.event.number || 'latest' }} # ephermal, prefixed for easy clean up of PR resources in s3 and dynamodb generated by terraform
4648
secrets: inherit
4749

48-
4950
tests:
5051
name: Tests
5152
needs: builds
5253
uses: ./.github/workflows/.tests.yml
5354
with:
54-
tag: ${{ github.event.number }}
55+
tag: ${{ github.event.number || 'latest' }}
56+
resume-resources-dev:
57+
name: Resume Resources Dev
58+
if: (github.event_name == 'workflow_dispatch')
59+
needs: [builds]
60+
uses: ./.github/workflows/resume-resources.yml
61+
secrets: inherit
5562
deploy-to-dev:
5663
name: Deploy to Dev
5764
if: (github.event_name == 'workflow_dispatch')
58-
needs: [builds, tests]
65+
needs: [resume-resources-dev]
5966
uses: ./.github/workflows/.deploy_stack.yml
6067
with:
6168
environment_name: dev
6269
command: apply
63-
tag: latest
70+
tag: manual
6471
app_env: dev
6572
secrets: inherit
6673
results:

GHA.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,29 @@ The workflows in this repository are organized into three main categories:
1414

1515
### `pr-open.yml`
1616

17-
**Trigger**: Pull request open or update
17+
**Trigger**:
18+
- Pull request open or update
19+
- Manual workflow dispatch (for deploying to dev environment)
1820

19-
**Purpose**: Validates the proposed changes to ensure they meet quality standards and work as expected.
21+
**Purpose**: Validates the proposed changes to ensure they meet quality standards and work as expected. Additionally allows manual deployment to the dev environment through workflow dispatch.
2022

2123
**Steps**:
22-
1. Builds container images for backend, frontend, and migrations, tagging them with the PR number
24+
1. Builds container images for backend, frontend, and migrations, tagging them with:
25+
- The PR number (for PR events)
26+
- 'manual' tag (for workflow dispatch events)
27+
- 'latest' tag
28+
- 'pr-{number}' tag
2329
2. Runs comprehensive tests on the codebase including:
2430
- Backend unit tests with a PostgreSQL service container
2531
- Frontend unit tests
2632
- Security scanning with Trivy
2733
3. SonarCloud analysis for code quality
28-
4. Creates a preview environment (when comments contain `/deploy`)
29-
5. Runs end-to-end tests using Playwright
34+
4. Plans infrastructure changes using Terraform/Terragrunt
35+
5. For workflow dispatch events:
36+
- Resumes any paused resources in the dev environment
37+
- Deploys the stack to the dev environment for testing
3038

31-
**Outputs**: Container images tagged with PR number, test results, SonarCloud reports
39+
**Outputs**: Container images with appropriate tags, test results, SonarCloud reports, and (for workflow dispatch) a deployed environment
3240

3341
### `pr-validate.yml`
3442

@@ -198,8 +206,10 @@ The workflows in this repository are organized into three main categories:
198206
The workflows use the following environment configurations:
199207

200208
1. **Development (dev)**: Used for continuous integration and feature testing
209+
- Can be deployed manually via workflow dispatch on the PR workflow
210+
- Serves as the target for merged PRs from the main branch
201211
2. **Testing (test)**: Used for QA and acceptance testing
202-
3. **Production (prod)**: Used for live production deployments
212+
3. **Production (prod)**: Used for live production deployments via the release workflow
203213

204214
## Required Secrets
205215

@@ -223,6 +233,12 @@ GitHub Event (PR, Push, etc.)
223233
│ │
224234
│ ├─── Test (calls .tests.yml)
225235
│ │
236+
│ ├─── Manual Workflow Dispatch─┐
237+
│ │ │
238+
│ │ ▼
239+
│ │ Resume Resources
240+
│ │ │
241+
│ │ ▼
226242
│ ├─── Deploy (calls .deploy_stack.yml)
227243
│ │ │
228244
│ │ └─── Deploy Components (database, api, frontend)
@@ -245,6 +261,10 @@ When customizing these workflows:
245261
3. Test changes thoroughly in isolation before merging
246262
4. Consider impacts on automated resource management
247263
5. Update documentation when changing workflow behavior
264+
6. When using manual workflow dispatch for deployments:
265+
- Ensure proper resource resume/pause mechanisms are in place
266+
- Use consistent tagging strategies between PR-based and manual deployments
267+
- Consider adding validation steps after manual deployments to verify success
248268

249269
## Troubleshooting
250270

0 commit comments

Comments
 (0)