Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy action #1

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gcloudignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
.gitignore

# Node.js dependencies:
node_modules/
node_modules/

# ignore test directory
test/

# ignore github actions yaml files
.github/
21 changes: 8 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# overall CI pipeline name
name: Build and test export server

# only run on master and stage branches
on:
push:
branches:
- master
- stage
# Run tests on EVERY branch and push
on: [push]

# Environment variables available to all jobs and steps in this workflow
env:
CI: true
PROJECT_ID: ${{secrets.GCLOUD_PROJECT_ID}}
APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}

# jobs are the different pipelines
jobs:
Expand All @@ -22,20 +16,21 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [10.14.2]

# define all the steps in the "build" stage
steps:
# use the checkout action
# use the checkout action to get repository contents
- uses: actions/checkout@v1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# Try to build and run tests again export server
- name: npm install, build, and test
- name: Run Tests
run: |
npm ci
npm run build --if-present
npm ci
npm test

46 changes: 46 additions & 0 deletions .github/workflows/deploy-gae.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# overall CI pipeline name
name: Deploy to GAE

# only run on master and stage branches
on:
push:
branches:
- master
- stage

# Environment variables available to all jobs and steps in this workflow
env:
# Project id
PROJECT_ID: ${{secrets.GCLOUD_PROJECT_ID}}
# GCP authorization credentials
APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
# define to use gcloud over gsutil
CLI: gcloud

# jobs are the different pipelines
jobs:
build:

# Define the OS and name
runs-on: ubuntu-latest
name: Publish and Deploy

# define all the steps in the "build" stage
steps:
# This step checks out a copy of your repository.
- uses: actions/checkout@v1
# This step checks out and logs in to gcloud
- name: Deploy Stage
if: github.ref == 'refs/heads/stage'
uses: actions-hub/gcloud@master
with:
# This step deploys to stage and the --no-promote flag prevents
# traffic from being split to this version
args: app deploy app-stage.yaml --version stage --no-promote
# This step checks out and logs in to gcloud
- name: Deploy Production
if: github.ref == 'refs/heads/master'
uses: actions-hub/gcloud@master
with:
# This step deploys to production
args: app deploy app.yaml --version master
44 changes: 0 additions & 44 deletions .gitlab-ci.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions app-stage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
runtime: nodejs10
instance_class: F4_1G
service: default
env_variables:
NODE_ENV: stage
# prevents all traffic from splitting immediately
# sends a "warmup" request to new version
inbound_services:
- warmup
4 changes: 4 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ instance_class: F4_1G
service: default
env_variables:
NODE_ENV: production
# prevents all traffic from splitting immediately
# sends a "warmup" request to new version
inbound_services:
- warmup
124 changes: 52 additions & 72 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,45 +141,35 @@ app.post('/', async (req, res) => {
// };
// });

// read file asynchronously in case it never returns
// fs.readFile(readFilePath, (err, imageFile) => {

// catch err
// if (err) {
// console.error(err);
// return res.status(500).send('Issue Reading File From Server');
// }

// request headers
let rHeaders = {
'Content-Type': '',
// 'Content-Length': '',
// 'Content-Disposition': `attachment; filename="${fileName}.${imgType}"`
};

// set appropriate mime/types
switch (imgType) {
case 'svg':
rHeaders['Content-Type'] = 'image/svg+xml';
// rHeaders['Content-Length'] = svgData.length;
break;
case 'pdf':
rHeaders['Content-Type'] = 'application/pdf';
// rHeaders['Content-Length'] = imageFile.length;
break;
case 'png':
case 'jpeg':
default:
rHeaders['Content-Type'] = `image/${imgType}`;
// rHeaders['Content-Length'] = imageFile.length;
}
// request headers
let rHeaders = {
'Content-Type': '',
// 'Content-Length': '',
// 'Content-Disposition': `attachment; filename="${fileName}.${imgType}"`
};

// set appropriate mime/types
switch (imgType) {
case 'svg':
rHeaders['Content-Type'] = 'image/svg+xml';
// rHeaders['Content-Length'] = svgData.length;
break;
case 'pdf':
rHeaders['Content-Type'] = 'application/pdf';
// rHeaders['Content-Length'] = imageFile.length;
break;
case 'png':
case 'jpeg':
default:
rHeaders['Content-Type'] = `image/${imgType}`;
// rHeaders['Content-Length'] = imageFile.length;
}

// write headers
res.writeHead(200, rHeaders);
// write headers
res.writeHead(200, rHeaders);

// end the buffer and send
return res.end(tmpBuffer);
// });
// end the buffer and send
return res.end(tmpBuffer);

} catch(e) {
console.error(e);
Expand Down Expand Up @@ -299,41 +289,31 @@ app.post('/json', async (req, res) => {
// };
// });

// read file asynchronously in case it never returns
// fs.readFile(readFilePath, (err, imageFile) => {

// catch err
// if (err) {
// console.error(err);
// return res.status(500).send('Issue Reading File From Server');
// }

// request headers
let rHeaders = {
'Content-Type': '',
// 'Content-Length': '',
// 'Content-Disposition': `attachment; filename="${fileName}.${imgType}"`
};

// set appropriate mime/types
switch (imgType) {
case 'pdf':
rHeaders['Content-Type'] = 'application/pdf';
// rHeaders['Content-Length'] = imageFile.length;
break;
case 'png':
case 'jpeg':
default:
rHeaders['Content-Type'] = `image/${imgType}`;
// rHeaders['Content-Length'] = imageFile.length;
}

// write headers
res.writeHead(200, rHeaders);

// end the buffer and send
return res.end(tmpBuffer);
// });
// request headers
let rHeaders = {
'Content-Type': '',
// 'Content-Length': '',
'Content-Disposition': `attachment; filename="${fileName}.${imgType}"`
};

// set appropriate mime/types
switch (imgType) {
case 'pdf':
rHeaders['Content-Type'] = 'application/pdf';
// rHeaders['Content-Length'] = imageFile.length;
break;
case 'png':
case 'jpeg':
default:
rHeaders['Content-Type'] = `image/${imgType}`;
// rHeaders['Content-Length'] = imageFile.length;
}

// write headers
res.writeHead(200, rHeaders);

// end the buffer and send
return res.end(tmpBuffer);
}
});

Expand Down
1 change: 0 additions & 1 deletion test.js

This file was deleted.

Loading