Skip to content

Commit df7da84

Browse files
authored
Merge pull request #129 from DDD-Community/feat/#123
[feat/#123] electron publish 추가, main.yml 수정
2 parents 26ac386 + c62536b commit df7da84

File tree

3 files changed

+225
-50
lines changed

3 files changed

+225
-50
lines changed

.github/workflows/main.yml

+57-30
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ on:
55
- develop
66
jobs:
77
build-and-deploy:
8-
runs-on: ubuntu-20.04
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [windows-latest, macos-latest]
12+
13+
outputs:
14+
build_outcome: ${{ steps.build_app.outcome }}
15+
deploy_outcome: ${{ steps.deploy_web.outcome }}
16+
917
steps:
1018
- name: Checkout source code
1119
uses: actions/checkout@v3
@@ -22,44 +30,62 @@ jobs:
2230
- name: Install dependencies
2331
run: yarn install
2432

25-
- name: Generate web and Electron builds
26-
id: build
33+
# 웹 빌드 및 S3 업로드 (macOS 환경에서만)
34+
- name: Build Web App
35+
id: build_web
36+
if: matrix.os == 'macos-latest'
2737
env:
2838
VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }}
2939
VITE_OAUTH_KAKAO_REST_API_KEY: ${{ secrets.VITE_OAUTH_KAKAO_REST_API_KEY }}
3040
VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE: ${{ secrets.VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE }}
3141
VITE_OAUTH_KAKAO_REDIRECT_URI: ${{ secrets.VITE_OAUTH_KAKAO_REDIRECT_URI }}
3242
run: |
33-
echo "Starting Web and Electron build..."
34-
yarn electron:build
43+
echo "Building web app..."
44+
yarn build
3545
36-
- name: Deploy builds to S3
37-
id: deploy
38-
if: steps.build.outcome == 'success'
46+
- name: Upload Web App to AWS S3
47+
id: deploy_web
48+
if: matrix.os == 'macos-latest'
3949
env:
4050
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
4151
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4252
run: |
4353
echo "Deploying web build to S3..."
44-
aws s3 sync --region ap-northeast-2 dist/web s3://alignlab-client --delete
45-
46-
echo "Deploying Electron build to S3..."
47-
ls out/make # 디렉토리 구조 확인
48-
ls out/make/squirrel.windows # 디렉토리 구조 확인
49-
aws s3 cp out/make/squirrel.windows/AlignLabInstaller.exe s3://alignlab-client/installer/AlignLabInstaller.exe --region ap-northeast-2
50-
aws s3 cp out/make/dmg/AlignLab.dmg s3://alignlab-client/installer/AlignLab.dmg --region ap-northeast-2
54+
aws s3 sync dist/web s3://alignlab-client --delete --region ap-northeast-2
5155
56+
# Electron 빌드 및 GitHub Releases로 Publish
57+
- name: Build and Publish Electron App
58+
id: build_app
59+
env:
60+
VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }}
61+
VITE_OAUTH_KAKAO_REST_API_KEY: ${{ secrets.VITE_OAUTH_KAKAO_REST_API_KEY }}
62+
VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE: ${{ secrets.VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE }}
63+
VITE_OAUTH_KAKAO_REDIRECT_URI: ${{ secrets.VITE_OAUTH_KAKAO_REDIRECT_URI }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: yarn electron:publish
66+
# CloudFront 캐시 무효화
67+
invalidate-cache:
68+
runs-on: ubuntu-20.04
69+
needs: [build-and-deploy]
70+
if: success()
71+
steps:
5272
- name: Invalidate CloudFront Cache
53-
if: steps.deploy.outcome == 'success'
5473
env:
5574
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5675
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
5776
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
5877
run: |
78+
echo "Invalidating CloudFront cache..."
5979
aws cloudfront create-invalidation --region ap-northeast-2 --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
6080
81+
82+
# Discord 알림 - 성공
83+
notify-success:
84+
runs-on: ubuntu-20.04
85+
needs: [build-and-deploy, invalidate-cache]
86+
if: success()
87+
steps:
6188
- name: Discord notification - Success
62-
if: steps.deploy.outcome == 'success'
6389
env:
6490
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
6591
DISCORD_USERNAME: GitHub
@@ -68,27 +94,28 @@ jobs:
6894
with:
6995
args: |
7096
🎉 배포가 성공적으로 완료되었습니다!
97+
다운로드 링크: https://github.com/${{ github.repository }}/releases/latest
98+
웹 앱 링크: https://alignlab-client.s3.ap-northeast-2.amazonaws.com/index.html
7199
브랜치: develop
72-
커밋: ${{ steps.get_commit_info.outputs.message }}
73-
작성자: ${{ steps.get_commit_info.outputs.author }}
100+
커밋: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.message }}
101+
작성자: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.author }}
74102
103+
# Discord 알림 - 실패
104+
notify-failure:
105+
runs-on: ubuntu-20.04
106+
needs: [build-and-deploy]
107+
if: failure()
108+
steps:
75109
- name: Discord notification - Failure
76-
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
77110
env:
78111
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
79-
DISCORD_USERNAME: GitHub
80-
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
81112
uses: Ilshidur/action-discord@master
82113
with:
83114
args: |
84-
❌ ${{ steps.build.outcome == 'failure' && '빌드 중' || '배포 중' }} 오류가 발생했습니다.
115+
❌ ${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && '빌드 중' || '배포 중' }} 오류가 발생했습니다.
85116
브랜치: develop
86-
커밋: ${{ steps.get_commit_info.outputs.message }}
117+
커밋: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.message }}
87118
작성자: <@${{ secrets.DISCORD_ID_1 }}>
88119
실패한 워크플로우: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
89-
${{ steps.build.outcome == 'failure' && '빌드 오류 메시지:' || '' }}
90-
${{ steps.build.outcome == 'failure' && steps.build.outputs.stderr || '' }}
91-
92-
- name: Check deploy result
93-
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
94-
run: exit 1
120+
${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && '빌드 오류 메시지:' || '' }}
121+
${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && needs.build-and-deploy.steps.build_app.outputs.stderr || '' }}

package.json

+18-19
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,21 @@
3333
"overwrite": true,
3434
"format": "ULFO"
3535
}
36-
},
37-
{
38-
"name": "@electron-forge/maker-zip",
39-
"platforms": ["darwin"]
40-
},
41-
{
42-
"name": "@electron-forge/maker-deb",
43-
"config": {
44-
"name": "alignlab",
45-
"productDescription": "AlignLab의 데스크톱 애플리케이션"
46-
}
47-
},
48-
{
49-
"name": "@electron-forge/maker-rpm",
50-
"config": {
51-
"name": "alignlab"
52-
}
5336
}
54-
]
37+
],
38+
"publishers": [
39+
{
40+
"name": "@electron-forge/publisher-github",
41+
"config": {
42+
"repository": {
43+
"owner": "DDD-Community",
44+
"name": "DDD-11-HERO-WEB"
45+
},
46+
"draft": false,
47+
"prerelease": false
48+
}
49+
}
50+
]
5551
}
5652
},
5753
"scripts": {
@@ -63,7 +59,9 @@
6359
"lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
6460
"electron:dev": "concurrently \"yarn dev\" \"cross-env DEV= tsc-watch -p tsconfig.electron.json --onSuccess \\\"electron .\\\"\"",
6561
"electron:preview": "yarn build && tsc -p tsconfig.electron.json && PREVIEW= electron .",
66-
"electron:build": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge make"
62+
"electron:build": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge make",
63+
"electron:publish": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge publish"
64+
6765
},
6866
"dependencies": {
6967
"@tanstack/react-query": "^5.51.23",
@@ -91,6 +89,7 @@
9189
"@electron-forge/maker-squirrel": "^6.0.4",
9290
"@electron-forge/maker-zip": "^6.0.4",
9391
"@electron-forge/maker-dmg": "^6.0.4",
92+
"@electron-forge/publisher-github": "^6.0.4",
9493
"@types/node": "^20.7.1",
9594
"@types/qs": "^6.9.7",
9695
"@types/react": "^18.0.26",

0 commit comments

Comments
 (0)