|
1 | | -# GitHub Actions for PSA Job Store |
| 1 | +# GitHub Actions |
2 | 2 |
|
3 | | -This directory contains the CI/CD workflows and custom actions used for automating the build, test, deployment, and maintenance processes of the PSA Job Store application. |
| 3 | +This directory contains the repository workflows and custom actions used for quality checks, image builds, database operations, releases, and security scanning. |
4 | 4 |
|
5 | 5 | ## Overview |
6 | 6 |
|
7 | | -The PSA Job Store project uses GitHub Actions for continuous integration and continuous deployment (CI/CD). These workflows automate various aspects of the development lifecycle, including: |
| 7 | +The current workflow set covers: |
8 | 8 |
|
9 | | -- Building Docker images |
10 | | -- Running unit tests |
11 | | -- Performing database migrations |
12 | | -- Deploying to OpenShift environments |
13 | | -- Running end-to-end tests |
14 | | -- Managing database backups and restores |
15 | | -- Security scanning with StackRox (Deprecated) |
| 9 | +- Application quality checks for backend, frontend, and temporal services |
| 10 | +- Docker image builds and Artifactory pushes |
| 11 | +- Database migration, backup, and restore tasks |
| 12 | +- Release automation |
| 13 | +- Pull request and branch security scanning |
16 | 14 |
|
17 | | -## Workflow Structure |
| 15 | +Workflow files live in `.github/workflows`, and reusable repository actions live in `.github/actions`. |
18 | 16 |
|
19 | | -The workflows are organized in the `.github/workflows` directory, while custom actions are in the `.github/actions` directory. |
| 17 | +## Core workflows |
20 | 18 |
|
21 | | -### Main Workflows |
| 19 | +### Quality assurance |
22 | 20 |
|
23 | | -#### 1. Build Docker Images (`build-apps.yml`) |
| 21 | +- `backend-qa.yml` |
| 22 | + - Pull request quality gate for `apps/backend-services` |
| 23 | + - Runs lint, type-check, and test coverage commands |
| 24 | +- `frontend-qa.yml` |
| 25 | + - Pull request quality gate for `apps/frontend` |
| 26 | + - Runs lint, type-check, and test commands |
| 27 | +- `temporal-qa.yml` |
| 28 | + - Pull request quality gate for `apps/temporal` |
| 29 | + - Runs lint, type-check, and test commands |
24 | 30 |
|
25 | | -Triggered on: |
| 31 | +These workflows intentionally avoid top-level `paths` filters so they always publish a check result for protected-branch pull requests. |
26 | 32 |
|
27 | | -- Push to main, stage, or develop branches |
28 | | -- Manual trigger |
| 33 | +### Build and release workflows |
29 | 34 |
|
30 | | -Key features: |
| 35 | +- `build-apps.yml` |
| 36 | + - Runs on pushes to `main` and `develop` |
| 37 | + - Detects changed applications, including shared Prisma inputs for backend and temporal |
| 38 | + - Builds and pushes Docker images to Artifactory |
| 39 | + - Scans built image digests with Grype |
| 40 | +- `build-instance-images.yml` |
| 41 | + - Manual workflow for building per-branch images |
| 42 | + - Scans built image digests with Grype |
| 43 | +- `migrate-db.yml` |
| 44 | + - Applies database migrations and coordinates downstream deployment work |
| 45 | +- `release.yml` |
| 46 | + - Release automation workflow |
31 | 47 |
|
32 | | -- Detects which applications have changed (api, app) |
33 | | -- Builds Docker images for changed applications |
34 | | -- Pushes images to Artifactory |
35 | | -- Triggers the database migration workflow |
| 48 | +### Database operations |
36 | 49 |
|
37 | | -#### 2. Database Migration (`migrate-db.yml`) |
| 50 | +- `db-backup-manual.yml` |
| 51 | + - Manual PostgreSQL backup workflow |
| 52 | +- `db-restore.yml` |
| 53 | + - Manual PostgreSQL restore workflow |
38 | 54 |
|
39 | | -Triggered on: |
| 55 | +## Security workflows |
40 | 56 |
|
41 | | -- Completion of the build workflow |
42 | | -- Manual trigger |
| 57 | +The repository security baseline now includes: |
43 | 58 |
|
44 | | -Key features: |
| 59 | +- `codeql.yml` |
| 60 | + - CodeQL analysis for TypeScript, Python, and GitHub Actions content |
| 61 | +- `dependency-review.yml` |
| 62 | + - Pull request dependency review for supported dependency changes |
| 63 | +- `python-dependency-audit.yml` |
| 64 | + - `uv` plus `pip-audit` coverage for `apps/image-service` |
| 65 | +- `hadolint.yml` |
| 66 | + - Dockerfile lint and security checks |
| 67 | +- `checkov.yml` |
| 68 | + - Blocking Dockerfile checks and advisory deployment/workflow scans |
45 | 69 |
|
46 | | -- Detects if there are new database migrations |
47 | | -- Applies Prisma migrations to the database |
48 | | -- Updates version information |
49 | | -- Triggers deployments for changed applications |
50 | | -#### 3. Unit Tests (`unit-tests.yml`) |
| 70 | +See `docs-md/security-scanning.md` for the operating model, blocking rules, and GitHub settings that must be enabled outside the repository. |
51 | 71 |
|
52 | | -Triggered on: |
| 72 | +## Custom actions |
53 | 73 |
|
54 | | -- Push to stage branch |
55 | | -- Manual trigger |
| 74 | +### `get-environment` |
56 | 75 |
|
57 | | -Key features: |
| 76 | +Determines the deployment environment name from the branch context. |
58 | 77 |
|
59 | | -- Builds common-kit library |
60 | | -- Runs Jest tests for React (app), NestJS (api), and common-kit |
| 78 | +### `migrate-db` |
61 | 79 |
|
62 | | -#### 5. Database Backup (`db-backup-manual.yml`) |
| 80 | +Runs the repository database migration logic. |
63 | 81 |
|
64 | | -Triggered on: |
| 82 | +### `trigger-deploy` |
65 | 83 |
|
66 | | -- Manual trigger |
| 84 | +Triggers deployment work in the target OpenShift environment. |
67 | 85 |
|
68 | | -Key features: |
| 86 | +## Environment configuration |
69 | 87 |
|
70 | | -- Creates a backup of the PostgreSQL database |
71 | | -- Allows specifying the cluster name, environment, and backup annotation |
| 88 | +The repository currently uses environment-specific secrets and deployment configuration. The reusable `get-environment` action maps: |
72 | 89 |
|
73 | | -#### 6. Database Restore (`db-restore.yml`) |
| 90 | +- `main` -> `prod` |
| 91 | +- `stage` -> `test` |
| 92 | +- other branches -> `dev` |
74 | 93 |
|
75 | | -Triggered on: |
| 94 | +Even though `build-apps.yml` now targets `main` and `develop`, the environment mapping still exists for workflows that may resolve other refs. |
76 | 95 |
|
77 | | -- Manual trigger |
| 96 | +## Required secrets |
78 | 97 |
|
79 | | -Key features: |
| 98 | +Common workflow secrets include: |
80 | 99 |
|
81 | | -- Restores a PostgreSQL database from a backup |
82 | | -- Allows specifying the cluster name, environment, and either a restore timestamp or backup ID |
| 100 | +- `OPENSHIFT_SERVER` |
| 101 | +- `OPENSHIFT_API_TOKEN` |
| 102 | +- `ARTIFACTORY_URL` |
| 103 | +- `ARTIFACTORY_SA_USERNAME` |
| 104 | +- `ARTIFACTORY_SA_PASSWORD` |
| 105 | +- Application-specific configuration values such as `VITE_*`, `REACT_APP_URL`, `DATABASE_URL`, and similar runtime/build inputs |
83 | 106 |
|
84 | | -#### 7. Security Scanning (`run-acs.yml`) (DEPRECATED) |
| 107 | +## Pipeline relationship |
85 | 108 |
|
86 | | -Triggered on: |
| 109 | +At a high level: |
87 | 110 |
|
88 | | -- Manual trigger |
89 | | - |
90 | | -Key features: |
91 | | - |
92 | | -- Runs StackRox security checks on Docker images |
93 | | -- Scans deployment configurations for security issues |
94 | | - |
95 | | -#### 8. Release Management (`release.yml`) (DEPRECATED) |
96 | | - |
97 | | -Triggered on: |
98 | | - |
99 | | -- Manual trigger |
100 | | - |
101 | | -Key features: |
102 | | - |
103 | | -- Creates a release pull request using Changesets |
104 | | - |
105 | | -## Custom Actions |
106 | | - |
107 | | -### 1. Trigger Deploy (`.github/actions/trigger-deploy`) |
108 | | - |
109 | | -Purpose: Triggers a deployment in OpenShift. |
110 | | - |
111 | | -Inputs: |
112 | | - |
113 | | -- OpenShift server |
114 | | -- API token |
115 | | -- Project to redeploy |
116 | | -- Deployment environment |
117 | | - |
118 | | -### 2. Migrate DB (`.github/actions/migrate-db`) |
119 | | - |
120 | | -Purpose: Executes database migrations. |
121 | | - |
122 | | -Inputs: |
123 | | - |
124 | | -- Deployment environment |
125 | | -- OpenShift server |
126 | | -- API token |
127 | | -- Database URL |
128 | | - |
129 | | -### 3. StackRox Scan (`.github/actions/stackrox-scan`) (DEPRECATED) |
130 | | - |
131 | | -Purpose: Scans Docker images for security vulnerabilities. |
132 | | - |
133 | | -Inputs: |
134 | | - |
135 | | -- Central endpoint |
136 | | -- API token |
137 | | -- Image to scan |
138 | | -- Output format |
139 | | - |
140 | | -### 4. StackRox Check (`.github/actions/stackrox-check`) (DEPRECATED) |
141 | | - |
142 | | -Purpose: Checks Docker images against security policies. |
143 | | - |
144 | | -Inputs: |
145 | | - |
146 | | -- Central endpoint |
147 | | -- API token |
148 | | -- Image to check |
149 | | - |
150 | | -### 5. StackRox DC Check (`.github/actions/stackrox-dc-check`) (DEPRECATED) |
151 | | - |
152 | | -Purpose: Checks deployment configurations against security policies. |
153 | | - |
154 | | -Inputs: |
155 | | - |
156 | | -- Path to deployment configuration |
157 | | -- Central endpoint |
158 | | -- API token |
159 | | - |
160 | | -## Environment Configuration |
161 | | - |
162 | | -The workflows use environment-specific configurations: |
163 | | - |
164 | | -- `dev` for the develop branch |
165 | | -- `test` for the stage branch |
166 | | -- `prod` for the main branch |
167 | | - |
168 | | -Each environment has its own set of secrets configured in GitHub. |
169 | | - |
170 | | -## Required Secrets |
171 | | - |
172 | | -The following secrets are required for the workflows to function properly: |
173 | | - |
174 | | -- `OPENSHIFT_SERVER`: The OpenShift server URL |
175 | | -- `OPENSHIFT_API_TOKEN`: API token for OpenShift authentication |
176 | | -- `ARTIFACTORY_URL`: URL of the Artifactory repository |
177 | | -- `ARTIFACTORY_SA_USERNAME`: Artifactory service account username |
178 | | -- `ARTIFACTORY_SA_PASSWORD`: Artifactory service account password |
179 | | -- `ROX_CENTRAL_ENDPOINT`: StackRox Central endpoint (DEPRECATED) |
180 | | -- `ROX_API_TOKEN`: StackRox API token (DEPRECATED) |
181 | | -- Various application-specific environment variables (VITE\_\*, SESSION_SECRET, etc.) |
182 | | - |
183 | | -## Workflow Dependencies |
184 | | - |
185 | | -The workflows are designed to work together in a pipeline: |
186 | | - |
187 | | -1. Code changes are pushed to a branch |
188 | | -2. `build-apps.yml` builds Docker images for changed applications |
189 | | -3. `migrate-db.yml` applies database migrations and triggers deployments |
190 | | - |
191 | | -## Manual Workflows |
192 | | - |
193 | | -Some workflows are designed to be triggered manually: |
194 | | - |
195 | | -- `db-backup-manual.yml` for creating database backups |
196 | | -- `db-restore.yml` for restoring from backups |
197 | | -- `run-acs.yml` for security scanning (DEPRECATED) |
198 | | -- `release.yml` for creating release pull requests (DEPRECATED) |
| 111 | +1. Pull requests run QA and security workflows. |
| 112 | +2. Protected-branch pushes build and scan images. |
| 113 | +3. Database and deployment workflows consume those build outputs as needed. |
0 commit comments