Skip to content

Commit 253caad

Browse files
Merge pull request #2 from bennu/feat/ci-cd
chore: Deploy static site to CDN
2 parents 8e7d507 + ea6f7c5 commit 253caad

File tree

3 files changed

+200
-49
lines changed

3 files changed

+200
-49
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy static site in AWS CDN
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
deploy_cdn:
6+
runs-on: ubuntu-latest
7+
if: startsWith(github.ref, 'refs/tags')
8+
env:
9+
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
10+
ID_DISTRIBUTION: ${{ secrets.ID_DISTRIBUTION }}
11+
PATH_BUILD: ${{ secrets.PATH_BUILD || 'out' }}
12+
NODE_VERSION: ${{ secrets.NODE_VERSION || '20.18.0' }}
13+
STAGE: ${{ secrets.STAGE || 'prod' }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ env.NODE_VERSION }}
20+
- name: build static page
21+
run: |
22+
npm install
23+
npm run build
24+
- name: Set up AWS CLI
25+
uses: aws-actions/configure-aws-credentials@v4
26+
with:
27+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
aws-region: ${{ secrets.AWS_REGION || 'us-east-1'}}
30+
- name: Upload to S3
31+
run: |
32+
aws configure set preview.cloudfront true
33+
find ${{ env.PATH_BUILD }} -type f -empty -delete
34+
aws s3 sync --delete ${{ env.PATH_BUILD }} s3://$S3_BUCKET_NAME/
35+
aws cloudfront create-invalidation --distribution-id $ID_DISTRIBUTION --path '/*'

next.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ const commonsEnvs = {
1919
const envs: EnvsType = {
2020
local: {
2121
...commonsEnvs,
22-
BASE_URL_MIGRATION: 'http://localhost:8080/'
22+
BASE_URL_MIGRATION: 'http://localhost:8080'
2323
},
2424
dev: {
2525
...commonsEnvs,
26-
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl/'
26+
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl'
2727
},
2828
stg: {
2929
...commonsEnvs,
30-
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl/'
30+
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl'
3131
},
3232
pro: {
3333
...commonsEnvs,
34-
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl/'
34+
BASE_URL_MIGRATION: 'https://api-bice.bennu.cl'
3535
}
3636
}
3737

@@ -45,7 +45,7 @@ const getStage = (): StageType => {
4545
}
4646

4747
const nextConfig: NextConfig = {
48-
output: 'standalone',
48+
output: 'export',
4949
env: envs[getStage()],
5050
typescript: {
5151
ignoreBuildErrors: true

0 commit comments

Comments
 (0)