diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 0000000..4d7d693 --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,17 @@ +# This file specifies files that are *not* uploaded to Google Cloud +# using gcloud. It follows the same syntax as .gitignore, with the addition of +# "#!include" directives (which insert the entries of the given .gitignore-style +# file at that point). +# +# For more information, run: +# $ gcloud topic gcloudignore +# +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or files +# from your .gitignore file, remove the corresponding line +# below: +.git +.gitignore + +# Node.js dependencies: +node_modules/ \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..0776f8f --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: deploy +on: + push: + branches: + - 'master' + - 'development' + +jobs: + deplay-staging: + name: GAE deplay + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Copy product.app.yaml + if: github.ref == 'refs/heads/master' + run: | + cp product.app.yaml app.yaml + echo ${{ secrets.PRODUCT_SECRET }} | base64 -d > secret.yaml + + + - name: Copy develop.app.yaml + if: github.ref == 'refs/heads/development' + run: | + cp develop.app.yaml app.yaml + echo ${{ secrets.DEVELOP_SECRET }} | base64 -d > secret.yaml + + - name: Deploy an App Engine app + id: deploy-app + uses: google-github-actions/deploy-appengine@v0.3.1 + with: + project_id: ${{ secrets.GCP_PROJECT_ID }} + deliverables: app.yaml + credentials: ${{ secrets.GCP_SA_KEY }} + version: v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index deed335..a77cf2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ dist/ .env +secret.yaml \ No newline at end of file diff --git a/develop.app.yaml b/develop.app.yaml new file mode 100644 index 0000000..9ff2694 --- /dev/null +++ b/develop.app.yaml @@ -0,0 +1,10 @@ +service: development +runtime: nodejs16 +instance_class: F1 + +automatic_scaling: + max_instances: 1 + min_instances: 0 + +includes: +- secret.yaml \ No newline at end of file diff --git a/package.json b/package.json index b5b9a32..d63a6cc 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,10 @@ "name": "kra-seller-api", "version": "1.0.0", "description": "", - "main": "api/main.js", + "main": "dist/main.js", "scripts": { - "start": "node api/main.js", + "start": "node dist/main.js", + "start:prod": "tsc && node dist/main.js", "build": "tsc", "dev": "nodemon" }, diff --git a/product.app.yaml b/product.app.yaml new file mode 100644 index 0000000..5282301 --- /dev/null +++ b/product.app.yaml @@ -0,0 +1,9 @@ +runtime: nodejs16 +instance_class: F1 + +automatic_scaling: + max_instances: 1 + min_instances: 0 + +includes: +- secret.yaml \ No newline at end of file diff --git a/sample.secret.yaml b/sample.secret.yaml new file mode 100644 index 0000000..e69de29