Skip to content

Commit

Permalink
Merge branch 'main' into update-edit-form-focus-and-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
natashapl committed Jun 20, 2024
2 parents eb17898 + f81bc8e commit 72089c4
Show file tree
Hide file tree
Showing 35 changed files with 1,608 additions and 267 deletions.
File renamed without changes.
45 changes: 45 additions & 0 deletions .github/workflows/_pr-create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create pull request to branch

on:
workflow_call:
inputs:
head:
type: string
default: ${{ github.ref_name }}
base:
required: true
type: string

env:
GH_TOKEN: ${{ github.token }}
HEAD: ${{ inputs.head }}
BASE: ${{ inputs.base }}

jobs:
create-pr:
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.pr-number.outputs.pull_request_number }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check for existing PR
id: check-pr
run: |
PR=$(gh pr list --base ${BASE} --head ${HEAD} --json number --jq '.[0].number')
echo "::set-output name=pr_exists::$PR"
- name: Create pull request
if: steps.check-pr.outputs.pr_exists == ''
run: |
gh pr create \
--label "autogenerated" \
--base ${BASE} --head ${HEAD} \
--title "Deploy to ${BASE}" \
--body "Automated PR to sync changes from ${HEAD} to ${BASE}."
- name: Get pull request number
id: pr-number
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:

- name: Initialize Terraform CDK configuration
shell: bash
working-directory: infra
run: |
cd infra
pnpm cdktf get
pnpm build:tsc
Expand All @@ -68,7 +68,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
shell: bash
working-directory: infra
run: |
cd infra
cf api https://api.fr.cloud.gov
DEPLOY_ENV=${DEPLOY_ENV} pnpm cdktf deploy --auto-approve
88 changes: 88 additions & 0 deletions .github/workflows/_terraform-plan-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Add Terraform CDK plan as comment on pull request

on:
workflow_call:
inputs:
deploy-env:
required: true
type: string

jobs:
terraform:
runs-on: ubuntu-latest
env:
DEPLOY_ENV: ${{ inputs.deploy-env }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Read node version from `.nvmrc` file
id: nvmrc
shell: bash
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- name: Install required node.js version
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvmrc.outputs.NODE_VERSION }}

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Initialize Terraform CDK configuration
shell: bash
working-directory: infra
run: |
pnpm cdktf get
pnpm build:tsc
- name: Install CloudFoundry CLI
run: |
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=v8&source=github" | sudo tar -zx --directory=/usr/local/bin
cf --version
- name: Configure CloudFoundry API endpoint
run: |
cf api https://api.fr.cloud.gov
- name: Synthesize Terraform configuration
working-directory: infra
run: |
DEPLOY_ENV=${DEPLOY_ENV} pnpm cdktf synth
- name: Get Terraform stack name
id: get_stack_name
working-directory: infra
run: |
DEPLOY_ENV=${DEPLOY_ENV} pnpm cdktf output --outputs-file outputs.json
echo "stack_name=$(jq -r 'keys[0]' outputs.json)" >> $GITHUB_OUTPUT
- name: Create Terraform plan
uses: dflook/terraform-plan@v1
with:
path: infra/cdktf.out/stacks/${{ steps.get_stack_name.outputs.stack_name }}
label: ${{ steps.get_stack_name.outputs.stack_name }}
18 changes: 18 additions & 0 deletions .github/workflows/add-terraform-plan-to-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Post Terraform plan to PR comment

on:
pull_request:
branches:
- staging
- main
types:
- opened
- synchronize
- reopened

jobs:
add-terraform-plan-to-staging-pr:
uses: ./.github/workflows/_terraform-plan-pr-comment.yml
secrets: inherit
with:
deploy-env: staging
13 changes: 13 additions & 0 deletions .github/workflows/create-pr-to-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Create PR from main to staging

on:
push:
branches:
- main

jobs:
create-pr-to-staging:
uses: ./.github/workflows/_pr-create.yml
secrets: inherit
with:
base: staging
11 changes: 3 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@ on:
push:
branches:
- main
tags:
- staging
workflow_dispatch:

env:
TAG_NAME: ${{ github.ref_name }}
REGISTRY: ghcr.io/gsa-tts/atj-platform

jobs:
build-image-doj:
uses: ./.github/workflows/_build-docker-image.yml
uses: ./.github/workflows/_docker-build-image.yml
secrets: inherit
with:
app-name: doj-demo

build-image-spotlight:
uses: ./.github/workflows/_build-docker-image.yml
uses: ./.github/workflows/_docker-build-image.yml
secrets: inherit
with:
app-name: spotlight

deploy:
needs: [build-image-doj, build-image-spotlight]
uses: ./.github/workflows/_apply-terraform.yml
uses: ./.github/workflows/_terraform-apply.yml
secrets: inherit
with:
deploy-env: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The project dependencies within the workspace are:
Additional documentation:

- [Architectural Decision Records (ADRs)](./documents/adr/)
- [Non-project contributions](./documents/value-created-log.md)
- [Release process](./documents/release-process.md)

## Overview

Expand Down
11 changes: 10 additions & 1 deletion apps/doj-demo/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
import react from '@astrojs/react';

import { getGithubRepository } from './src/lib/github';

const githubRepository = await getGithubRepository(process.env);

// https://astro.build/config
export default defineConfig({
output: 'server',
trailingSlash: 'always',
trailingSlash: 'never',
base: addTrailingSlash(process.env.BASEURL || ''),
adapter: node({
mode: 'standalone',
Expand All @@ -18,6 +22,11 @@ export default defineConfig({
server: {
port: 4322,
},
vite: {
define: {
'import.meta.env.GITHUB': JSON.stringify(githubRepository),
},
},
});

function addTrailingSlash(path) {
Expand Down
8 changes: 4 additions & 4 deletions apps/doj-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.5.6",
"@astrojs/node": "^8.2.3",
"@astrojs/react": "^3.0.9",
"@astrojs/check": "^0.7.0",
"@astrojs/node": "^8.3.1",
"@astrojs/react": "^3.6.0",
"@atj/design": "workspace:*",
"@atj/forms": "workspace:*",
"astro": "^4.4.11",
"astro": "^4.10.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/doj-demo/public/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/doj-demo/public/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/doj-demo/public/favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/doj-demo/public/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions apps/doj-demo/src/components/AppFormManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@atj/design';

import { getAppContext } from '../context';
import { getFormManagerUrlById, getFormUrl } from '../routes';

export default function () {
const ctx = getAppContext();
Expand All @@ -19,6 +20,8 @@ export default function () {
editComponents: defaultPatternEditComponents,
formService: ctx.formService,
uswdsRoot: ctx.uswdsRoot,
urlForForm: getFormUrl,
urlForFormManager: getFormManagerUrlById,
}}
/>
);
Expand Down
16 changes: 16 additions & 0 deletions apps/doj-demo/src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
---
import { type GithubRepository, getBranchTreeUrl } from '../lib/github';
type Props = {
github: GithubRepository;
};
const { github } = Astro.props;
---

<footer class="usa-footer usa-footer--slim">
Expand All @@ -18,6 +24,16 @@
10x
</a>
</li>
<li
class="mobile-lg:grid-col-6 desktop:grid-col-auto usa-footer__primary-content"
>
<a
class="usa-footer__primary-link"
href={getBranchTreeUrl(github, true)}
>
Github repository
</a>
</li>
</ul>
</nav>
</div>
Expand Down
35 changes: 22 additions & 13 deletions apps/doj-demo/src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,24 @@ const getNavLinkClasses = (url: string) => {

<div class="usa-overlay"></div>
<header class="usa-header usa-header--extended">
<div class="usa-navbar">
<div class="usa-logo">
<em class="usa-logo__text">
<a href={routes.getHomeUrl()} title="10x Access to Justice">
<img src={logoSvg.src} role="img" alt="10x Logo" />
<span>Access to Justice Form Builder</span>
</a>
</em>
<div class="topHeaderBanner bg-yellow">
<span class="usa-navbar height-auto display-block padding-2"
><strong>STAGING SERVER</strong> - No changes you make here will be visible
to the public.</span
>
</div>
<div class="bg-base-darkest">
<div class="usa-navbar">
<div class="usa-logo">
<em class="usa-logo__text">
<a href={routes.getHomeUrl()} title="10x Access to Justice">
<img src={logoSvg.src} role="img" alt="10x Logo" />
<span class="text-white">DOJ A2J Forms</span>
</a>
</em>
</div>
<button type="button" class="usa-menu-btn">Menu</button>
</div>
<button type="button" class="usa-menu-btn">Menu</button>
</div>
<nav aria-label="Primary navigation" class="usa-nav">
<div class="usa-nav__inner">
Expand All @@ -35,14 +43,15 @@ const getNavLinkClasses = (url: string) => {
<li class="usa-nav__primary-item">
<a
href={routes.getHomeUrl()}
class={getNavLinkClasses(routes.getHomeUrl())}><span>Home</span></a
class={getNavLinkClasses(routes.getHomeUrl())}
><span>My Forms</span></a
>
</li>
<li class="usa-nav__primary-item">
<a
href={routes.getManageUrl()}
class={getNavLinkClasses(routes.getManageUrl())}
><span>Manage forms</span></a
href={routes.getStorybookUrl()}
class={getNavLinkClasses(routes.getStorybookUrl())}
><span>Storybook</span></a
>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion apps/doj-demo/src/components/UsaBanner.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import usFlagSmall from '@atj/design/static/uswds/img/us_flag_small.png';
</div>
<div class="grid-col-fill tablet:grid-col-auto">
<p class="usa-banner__header-text">
An official website of the United States government
A demo website of the United States government
</p>
<p class="usa-banner__header-action" aria-hidden="true">
Here’s how you know
Expand Down
Loading

0 comments on commit 72089c4

Please sign in to comment.