Skip to content

Commit 89bf493

Browse files
authored
Merge pull request #224 from navapbc/seant/8
[Sean] Issue 8 - Add app-flask and app-nextjs
2 parents 01fd3c6 + 5b02ab6 commit 89bf493

File tree

300 files changed

+35335
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+35335
-26
lines changed

.github/workflows/cd-app-flask.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy app-flask
2+
# Need to set a default value for when the workflow is triggered from a git push
3+
# which bypasses the default configuration for inputs
4+
run-name: Deploy ${{inputs.version || 'main' }} to app-flask ${{ inputs.environment || 'dev' }}
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
paths:
11+
- "app-flask/**"
12+
- "bin/**"
13+
- "infra/**"
14+
workflow_dispatch:
15+
inputs:
16+
environment:
17+
description: Environment to deploy to
18+
required: true
19+
default: "dev"
20+
type: choice
21+
options:
22+
- dev
23+
- staging
24+
- prod
25+
version:
26+
required: true
27+
default: "main"
28+
description: Tag or branch or SHA to deploy
29+
30+
jobs:
31+
deploy:
32+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
33+
uses: ./.github/workflows/deploy.yml
34+
with:
35+
app_name: "app-flask"
36+
environment: ${{ inputs.environment || 'dev' }}
37+
version: ${{ inputs.version || 'main' }}
38+
secrets: inherit
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy Storybook
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- app-nextjs/**
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow access to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Cancel any older in-progress runs of this workflow
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version-file: ./app-nextjs/package.json
33+
cache-dependency-path: ./app-nextjs/package-lock.json # or yarn.lock
34+
cache: npm # or yarn
35+
- name: Setup Pages
36+
uses: actions/configure-pages@v5
37+
id: pages_config
38+
- name: Install dependencies
39+
run: npm ci
40+
working-directory: ./app-nextjs
41+
- name: Build
42+
run: NEXT_PUBLIC_BASE_PATH=${{ steps.pages_config.outputs.base_path }} npm run storybook-build
43+
working-directory: ./app-nextjs
44+
- name: Upload artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: ./app-nextjs/storybook-static
48+
49+
deploy:
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.hosting.outputs.page_url }}
53+
runs-on: ubuntu-latest
54+
needs: build
55+
steps:
56+
- name: Deploy to GitHub Pages
57+
id: hosting
58+
uses: actions/deploy-pages@v4
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy app-nextjs
2+
# Need to set a default value for when the workflow is triggered from a git push
3+
# which bypasses the default configuration for inputs
4+
run-name: Deploy ${{inputs.version || 'main' }} to app-nextjs ${{ inputs.environment || 'dev' }}
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
paths:
11+
- "app-nextjs/**"
12+
- "bin/**"
13+
- "infra/**"
14+
workflow_dispatch:
15+
inputs:
16+
environment:
17+
description: Environment to deploy to
18+
required: true
19+
default: "dev"
20+
type: choice
21+
options:
22+
- dev
23+
- staging
24+
- prod
25+
version:
26+
required: true
27+
default: "main"
28+
description: Tag or branch or SHA to deploy
29+
30+
jobs:
31+
deploy:
32+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
33+
uses: ./.github/workflows/deploy.yml
34+
with:
35+
app_name: "app-nextjs"
36+
environment: ${{ inputs.environment || 'dev' }}
37+
version: ${{ inputs.version || 'main' }}
38+
secrets: inherit
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI Infra Service Checks - app-flask
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- infra/app-flask/service/**
9+
- infra/modules/**
10+
- infra/test/**
11+
- .github/workflows/ci-app-flask-infra-service.yml
12+
pull_request:
13+
paths:
14+
- infra/app-flask/service/**
15+
- infra/modules/**
16+
- infra/test/**
17+
- .github/workflows/ci-app-flask-infra-service.yml
18+
workflow_dispatch:
19+
inputs:
20+
version:
21+
required: true
22+
default: "main"
23+
description: Tag or branch or SHA to test
24+
25+
jobs:
26+
build-and-publish:
27+
name: Build
28+
uses: ./.github/workflows/build-and-publish.yml
29+
with:
30+
app_name: app-flask
31+
ref: ${{ inputs.version || github.ref }}
32+
33+
infra-test-e2e:
34+
name: Test service
35+
runs-on: ubuntu-latest
36+
needs: [build-and-publish]
37+
38+
permissions:
39+
contents: read
40+
id-token: write
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
ref: ${{ inputs.version || github.ref }}
46+
47+
- name: Set up Terraform
48+
uses: ./.github/actions/setup-terraform
49+
50+
- uses: actions/setup-go@v5
51+
with:
52+
go-version-file: "infra/test/go.mod"
53+
54+
- name: Configure AWS credentials
55+
uses: ./.github/actions/configure-aws-credentials
56+
with:
57+
app_name: app-flask
58+
# Run infra CI on dev environment
59+
environment: dev
60+
61+
- name: Run Terratest
62+
run: make infra-test-service APP_NAME=app-flask
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Update OpenAPI docs so that they remain up to date with the application
2+
name: Update OpenAPI Docs
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- app-flask/**
8+
- Makefile
9+
- .github/workflows/ci-app-flask-openapi.yml
10+
11+
defaults:
12+
run:
13+
working-directory: ./app-flask
14+
15+
# Only trigger run one update of the OpenAPI spec at a time on the branch.
16+
# If new commits are pushed to the branch, cancel in progress runs and start
17+
# a new one.
18+
concurrency:
19+
group: ${{ github.head_ref }}
20+
cancel-in-progress: true
21+
22+
23+
jobs:
24+
update-openapi-docs:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
# Checkout the feature branch associated with the pull request
30+
ref: ${{ github.head_ref }}
31+
32+
- name: Update OpenAPI spec
33+
run: make openapi-spec
34+
35+
- name: Push changes
36+
run: |
37+
git config user.name nava-platform-bot
38+
git config user.email platform-admins@navapbc.com
39+
git add --all
40+
# Commit changes (if no changes then no-op)
41+
git diff-index --quiet HEAD || git commit -m "Update OpenAPI spec"
42+
git push
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI app-flask PR Environment Checks
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
pr_number:
6+
required: true
7+
type: string
8+
commit_hash:
9+
required: true
10+
type: string
11+
pull_request:
12+
13+
jobs:
14+
update:
15+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
16+
uses: ./.github/workflows/pr-environment-checks.yml
17+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.state == 'open'
18+
with:
19+
app_name: "app-flask"
20+
environment: "dev"
21+
pr_number: ${{ inputs.pr_number || github.event.number }}
22+
commit_hash: ${{ inputs.commit_hash || github.event.pull_request.head.sha }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI app-flask PR Environment Destroy
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
pr_number:
6+
required: true
7+
type: string
8+
pull_request_target:
9+
types: [closed]
10+
11+
jobs:
12+
destroy:
13+
name: " " # GitHub UI is noisy when calling reusable workflows, so use whitespace for name to reduce noise
14+
uses: ./.github/workflows/pr-environment-destroy.yml
15+
with:
16+
app_name: "app-flask"
17+
environment: "dev"
18+
pr_number: ${{ inputs.pr_number || github.event.number }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI Vulnerability Scans - app-flask
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- app-flask/**
9+
- .grype.yml
10+
- .hadolint.yaml
11+
- .trivyignore
12+
- .github/workflows/vulnerability-scans.yml
13+
- .github/workflows/ci-app-flask-vulnerability-scans.yml
14+
pull_request:
15+
paths:
16+
- app-flask/**
17+
- .grype.yml
18+
- .hadolint.yaml
19+
- .trivyignore
20+
- .github/workflows/vulnerability-scans.yml
21+
- .github/workflows/ci-app-flask-vulnerability-scans.yml
22+
23+
jobs:
24+
vulnerability-scans:
25+
name: Vulnerability Scans
26+
uses: ./.github/workflows/vulnerability-scans.yml
27+
with:
28+
app_name: "app-flask"

.github/workflows/ci-app-flask.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI - app-flask
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- app-flask/**
9+
- .github/workflows/ci-app-flask.yml
10+
pull_request:
11+
paths:
12+
- app-flask/**
13+
- .github/workflows/ci-app-flask.yml
14+
15+
defaults:
16+
run:
17+
working-directory: ./app-flask
18+
19+
jobs:
20+
# As an enhancement, it is possible to share the built docker image and share
21+
# it across jobs as described in:
22+
# https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow
23+
lint:
24+
name: Lint
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Run format check
30+
run: make format-check
31+
32+
- name: Run linting
33+
run: make lint
34+
security-scan:
35+
name: Security scan
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Run security linting
41+
run: make lint-security
42+
test:
43+
name: Test
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Start tests
49+
run: |
50+
make test-audit
51+
make test-coverage

0 commit comments

Comments
 (0)