Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #684 from guardian/jw-test-gh-action
Browse files Browse the repository at this point in the history
Add PR deployment action
  • Loading branch information
jacobwinch authored Sep 14, 2020
2 parents 5f8e3b6 + ec9b9e8 commit 15dd0c8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pr-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PR Deployment

on:
pull_request:
types: [labeled]

jobs:
pr_deployment:

# We only want to run the app if the PR Deployment label has been added
if: ${{ github.event.label.id == 2340278517 }}

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- uses: actions/cache@v2
with:
path: ~/.npm
key: node-${{ hashFiles('**/package-lock.json') }}
restore-keys: node-
- name: install
run: npm ci
- name: run
run: |
npm install -g ngrok
npm run watch &
timeout 1h ngrok http 8080 -log=stdout -host-header=rewrite | \
grep --line-buffered -o 'https://.*' | \
xargs -L1 -I{} -t \
curl -X POST -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} -d "{\"state\":\"success\", \"target_url\":\"{}\", \"context\":\"PR deployment\", \"description\":\"This PR is now live until `date -d "+1 hour" "+%a %H:%M"`. Click details to access it ->\"}"
env:
APIS_IMG_SALT: ${{ secrets.APIS_IMG_SALT }}
CAPI_KEY: ${{ secrets.CAPI_KEY }}
TZ: "/usr/share/zoneinfo/Europe/London"
1 change: 1 addition & 0 deletions src/logger/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ServerLogger implements LoggerFunctions {
} else {
winstonConfig = {
level: 'debug',
silent: !!process.env.GITHUB_ACTIONS,
defaultMeta: {
app: App,
stack: Stack,
Expand Down
6 changes: 6 additions & 0 deletions src/server/ssmConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export async function getConfigValue(
key: string,
defaultValue?: string,
): Promise<string | undefined> {

if (process.env.GITHUB_ACTIONS) {
// my.var.name is not a valid env var
return process.env[key.toUpperCase().replace(/\./g, '_')];
}

const conf = await fetchConfig();

if (conf[key]) {
Expand Down

0 comments on commit 15dd0c8

Please sign in to comment.