Skip to content

Commit

Permalink
Merge pull request #453 from UN-OCHA/env/stage
Browse files Browse the repository at this point in the history
🚀 Release `v1.9.0` and deploy to production
  • Loading branch information
Pl217 authored Jun 25, 2024
2 parents 1ba696f + 93729a3 commit 4f1aa10
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 40 deletions.
13 changes: 0 additions & 13 deletions .github/ci.sh

This file was deleted.

44 changes: 31 additions & 13 deletions .github/workflow.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,38 @@
"stagingEnvironmentBranch": "env/stage",
"repoType": "node",
"developmentEnvironmentBranches": ["env/red.dev", "env/blue.dev"],
"docker": {
"path": ".",
"args": {
"commitSha": "COMMIT_SHA",
"treeSha": "TREE_SHA"
},
"environmentVariables": {
"commitSha": "HPC_ACTIONS_COMMIT_SHA",
"treeSha": "HPC_ACTIONS_TREE_SHA"
"dockerImages": [
{
"dockerfilePath": ".",
"appName": "hpc-cdm",
"args": {
"commitSha": "COMMIT_SHA",
"treeSha": "TREE_SHA",
"appToBuild": "APP_TO_BUILD"
},
"environmentVariables": {
"commitSha": "HPC_ACTIONS_COMMIT_SHA",
"treeSha": "HPC_ACTIONS_TREE_SHA"
},
"repository": "public.ecr.aws/unocha/hpc-cdm",
"skipLogin": true
},
"repository": "public.ecr.aws/unocha/hpc-cdm",
"skipLogin": true
},
"ci": ["./.github/ci.sh"],
{
"dockerfilePath": ".",
"appName": "hpc-ftsadmin",
"args": {
"commitSha": "COMMIT_SHA",
"treeSha": "TREE_SHA",
"appToBuild": "APP_TO_BUILD"
},
"environmentVariables": {
"commitSha": "HPC_ACTIONS_COMMIT_SHA",
"treeSha": "HPC_ACTIONS_TREE_SHA"
},
"repository": "public.ecr.aws/unocha/hpc-ftsadmin",
"skipLogin": true
}
],
"mergebackLabels": ["mergeback"],
"deployments": {
"environments": [
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@ jobs:
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install NPM Packages
run: npm ci

- name: Derive appropriate SHAs for base and head for `nx affected` commands
# Production deployments are triggered by push events and not when a pull request
# is open, so we cannot use branch names when determining affected apps
if: ${{ github.ref_name == 'env/prod' }}
uses: nrwl/nx-set-shas@v4
with:
main-branch-name: 'env/prod'
error-on-no-successful-workflow: true

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -31,7 +46,32 @@ jobs:
env:
AWS_REGION: us-east-1

- name: Lint affected apps
run: npm run lint

- name: Build affected apps
run: npx nx affected:build

- name: Get affected apps
id: affectedApps
run: |
if [[ -z "${{ env.NX_BASE }}" ]]; then
BASE_REF=${GITHUB_BASE_REF}
else
BASE_REF=${{ env.NX_BASE }}
fi
if [[ -z "${{ env.NX_HEAD }}" ]]; then
HEAD_REF=${GITHUB_HEAD_REF}
else
HEAD_REF=${{ env.NX_HEAD }}
fi
echo "AFFECTED_APPS=$(npx nx show projects --affected --type app --exclude=*-e2e --base=$BASE_REF --head=$HEAD_REF | xargs | tr ' ' ',')" >> "$GITHUB_OUTPUT"
- uses: UN-OCHA/hpc-actions@develop
with:
apps-to-build: ${{ steps.affectedApps.outputs.AFFECTED_APPS }}
env:
CONFIG_FILE: .github/workflow.config.json
GITHUB_TOKEN: ${{ secrets.HPC_BOT_TOKEN }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM public.ecr.aws/unocha/nodejs-builder:20-alpine AS builder
WORKDIR /srv/src
COPY . .
ARG ENVIRONMENT=production
ARG APP_TO_BUILD
RUN npm run remove-unneeded-deps && \
npm install && \
# Output path is relative to working directory
npm run build hpc-cdm -- --output-path=dist/ --configuration=$ENVIRONMENT
npm run build ${APP_TO_BUILD} -- --output-path=dist/ --configuration=$ENVIRONMENT

FROM public.ecr.aws/unocha/nginx:stable-beagle

Expand Down
32 changes: 32 additions & 0 deletions libs/hpc-data/src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ export const INTEGER_ARRAY_FROM_STRING = new t.Type<number[], number[]>(
t.identity
);

export const STRING_FROM_SINGLE_ELEMENT_ARRAY = new t.Type<string, string>(
'STRING_FROM_SINGLE_ELEMENT_ARRAY',
t.string.is,
(v, c) => {
if (Array.isArray(v) && v.length === 1 && typeof v[0] === 'string') {
return t.success(v[0]);
}

return t.failure(v, c);
},
t.identity
);

/**
* Accepts either a boolean, or a string of a boolean.
*/
Expand Down Expand Up @@ -98,6 +111,18 @@ export const BOOLEAN_FROM_STRING = new t.Type<boolean, boolean>(
t.identity
);

export const TRIMMED_STRING = new t.Type<string, string>(
'TRIMMED_STRING',
t.string.is,
(v, c) => {
if (typeof v === 'string') {
return t.success(v.trim());
}
return t.failure(v, c);
},
t.identity
);

/**
* A file BLOB
*/
Expand All @@ -114,6 +139,13 @@ export const BLOB = new t.Type<Blob, Blob>(
t.identity
);

export const BUFFER = new t.Type<Buffer, Buffer, any>(
'Buffer',
(v): v is Buffer => v instanceof Buffer,
(v, c) => (v instanceof Buffer ? t.success(v) : t.failure(v, c)),
t.identity
);

/**
* A file Buffer
*/
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unocha",
"version": "1.8.0",
"version": "1.9.0",
"license": "Apache-2.0",
"scripts": {
"remove-unneeded-deps": "node tools/remove-unneeded-deps.js",
Expand Down

0 comments on commit 4f1aa10

Please sign in to comment.