Skip to content

Commit f924c0c

Browse files
authored
Merge pull request #86 from mosu-dev/main
Release: Github Action SSG, ISR 정적페이지 배포 테스트
2 parents 0193707 + 8a03232 commit f924c0c

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

.github/workflows/depoly-production.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
AWS_REGION: ap-northeast-2
1111
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
12+
WORKING_DIRECTORY: mosu-app
1213

1314
jobs:
1415
build:
@@ -23,29 +24,44 @@ jobs:
2324
with:
2425
node-version: "22"
2526
cache: "yarn"
27+
cache-dependency-path: ${{ env.WORKING_DIRECTORY }}/yarn.lock
28+
29+
- name: Cache Next.js build
30+
uses: actions/cache@v4
31+
with:
32+
path: ${{ env.WORKING_DIRECTORY }}/.next/cache
33+
key: ${{ runner.os }}-nextjs-${{ hashFiles(format('{0}/yarn.lock', env.WORKING_DIRECTORY)) }}-${{ hashFiles(format('{0}/**/*.js', env.WORKING_DIRECTORY), format('{0}/**/*.tsx', env.WORKING_DIRECTORY)) }}
34+
restore-keys: |
35+
${{ runner.os }}-nextjs-${{ hashFiles(format('{0}/yarn.lock', env.WORKING_DIRECTORY)) }}-
2636
2737
- name: Install dependencies
2838
run: yarn install --frozen-lockfile
29-
working-directory: ./mosu-app
39+
working-directory: ${{ env.WORKING_DIRECTORY }}
3040

3141
- name: Build Application
3242
run: yarn build
33-
working-directory: ./mosu-app
43+
working-directory: ${{ env.WORKING_DIRECTORY }}
3444

35-
- name: Upload Build Artifacts (.next)
45+
- name: Archive .next directory
46+
run: tar -czf next-build.tar.gz -C ${{ env.WORKING_DIRECTORY }} .next
47+
48+
- name: Upload Build Artifact
3649
uses: actions/upload-artifact@v4
3750
with:
38-
name: mosu-app-build
39-
path: ./mosu-app/.next
51+
name: mosu-app-build-archive
52+
path: next-build.tar.gz
53+
if-no-files-found: error
4054

4155
- name: Upload Public Directory
4256
uses: actions/upload-artifact@v4
4357
with:
4458
name: mosu-app-public
45-
path: ./mosu-app/public
59+
path: ${{ env.WORKING_DIRECTORY }}/public/
60+
if-no-files-found: error
4661

4762
approve:
4863
name: Await for Approval
64+
needs: build
4965
runs-on: ubuntu-latest
5066
environment: production
5167
steps:
@@ -60,22 +76,26 @@ jobs:
6076
id-token: write
6177
contents: read
6278
steps:
63-
- name: Download Build Artifacts
79+
- name: Download Build Artifact
6480
uses: actions/download-artifact@v4
6581
with:
66-
name: mosu-app-build
67-
path: ./.next
82+
name: mosu-app-build-archive
6883

6984
- name: Download Public Directory
7085
uses: actions/download-artifact@v4
7186
with:
7287
name: mosu-app-public
7388
path: ./public
7489

90+
- name: Extract Build Artifact
91+
run: tar -xzf next-build.tar.gz
92+
7593
- name: Configure AWS Credentials
7694
uses: aws-actions/configure-aws-credentials@v4
7795
with:
7896
aws-region: ${{ env.AWS_REGION }}
97+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
98+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
7999

80100
- name: Upload Public Directory to S3
81101
run: aws s3 sync ./public s3://${{ env.AWS_S3_BUCKET_NAME }} --delete

0 commit comments

Comments
 (0)