forked from amplication/amplication
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (71 loc) · 2.55 KB
/
deployment.static.template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: _Reusable Deployment Static template
on:
workflow_call:
inputs:
environment-name:
type: string
description: Environment to deploy to.
required: true
project-name:
type: string
description: Project (amplication application component) to deploy.
required: true
deploy-type:
type: string
description: Deployment type, valid options are 'container' or 'static'.
required: true
secrets:
NX_CLOUD_ACCESS_TOKEN:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
deployment-static:
name: Deployment static
if: ${{ inputs.deploy-type == 'static' }}
environment:
name: ${{ inputs.environment-name }}
url: ${{ vars.AMPLICATION_URL }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version-file: "package.json"
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Cache global node modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
run: npm ci
- uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy to S3 bucket
run: |
project=${{ inputs.project-name }}
prefix="amplication-"
project=${project#$prefix}
if [[ "$project" == "client" ]];
then
if [[ "${{ inputs.environment-name }}" == "production" ]];
then
npx nx deploy:static --configuration="${{ inputs.environment-name }}" --bucket-name="app.amplication.com" --distribution-id="${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}"
else
npx nx deploy:static --configuration="${{ inputs.environment-name }}" --bucket-name="app.amplication-${{ inputs.environment-name }}.com" --distribution-id="${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}"
fi;
fi;