Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat/#123] electron publish 추가, main.yml 수정 #129

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 57 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ on:
- develop
jobs:
build-and-deploy:
runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]

outputs:
build_outcome: ${{ steps.build_app.outcome }}
deploy_outcome: ${{ steps.deploy_web.outcome }}

steps:
- name: Checkout source code
uses: actions/checkout@v3
Expand All @@ -22,44 +30,62 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Generate web and Electron builds
id: build
# 웹 빌드 및 S3 업로드 (macOS 환경에서만)
- name: Build Web App
id: build_web
if: matrix.os == 'macos-latest'
env:
VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }}
VITE_OAUTH_KAKAO_REST_API_KEY: ${{ secrets.VITE_OAUTH_KAKAO_REST_API_KEY }}
VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE: ${{ secrets.VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE }}
VITE_OAUTH_KAKAO_REDIRECT_URI: ${{ secrets.VITE_OAUTH_KAKAO_REDIRECT_URI }}
run: |
echo "Starting Web and Electron build..."
yarn electron:build
echo "Building web app..."
yarn build

- name: Deploy builds to S3
id: deploy
if: steps.build.outcome == 'success'
- name: Upload Web App to AWS S3
id: deploy_web
if: matrix.os == 'macos-latest'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
echo "Deploying web build to S3..."
aws s3 sync --region ap-northeast-2 dist/web s3://alignlab-client --delete

echo "Deploying Electron build to S3..."
ls out/make # 디렉토리 구조 확인
ls out/make/squirrel.windows # 디렉토리 구조 확인
aws s3 cp out/make/squirrel.windows/AlignLabInstaller.exe s3://alignlab-client/installer/AlignLabInstaller.exe --region ap-northeast-2
aws s3 cp out/make/dmg/AlignLab.dmg s3://alignlab-client/installer/AlignLab.dmg --region ap-northeast-2
aws s3 sync dist/web s3://alignlab-client --delete --region ap-northeast-2

# Electron 빌드 및 GitHub Releases로 Publish
- name: Build and Publish Electron App
id: build_app
env:
VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }}
VITE_OAUTH_KAKAO_REST_API_KEY: ${{ secrets.VITE_OAUTH_KAKAO_REST_API_KEY }}
VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE: ${{ secrets.VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE }}
VITE_OAUTH_KAKAO_REDIRECT_URI: ${{ secrets.VITE_OAUTH_KAKAO_REDIRECT_URI }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn electron:publish
# CloudFront 캐시 무효화
invalidate-cache:
runs-on: ubuntu-20.04
needs: [build-and-deploy]
if: success()
steps:
- name: Invalidate CloudFront Cache
if: steps.deploy.outcome == 'success'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
run: |
echo "Invalidating CloudFront cache..."
aws cloudfront create-invalidation --region ap-northeast-2 --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"


# Discord 알림 - 성공
notify-success:
runs-on: ubuntu-20.04
needs: [build-and-deploy, invalidate-cache]
if: success()
steps:
- name: Discord notification - Success
if: steps.deploy.outcome == 'success'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
DISCORD_USERNAME: GitHub
Expand All @@ -68,27 +94,28 @@ jobs:
with:
args: |
🎉 배포가 성공적으로 완료되었습니다!
다운로드 링크: https://github.com/${{ github.repository }}/releases/latest
웹 앱 링크: https://alignlab-client.s3.ap-northeast-2.amazonaws.com/index.html
브랜치: develop
커밋: ${{ steps.get_commit_info.outputs.message }}
작성자: ${{ steps.get_commit_info.outputs.author }}
커밋: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.message }}
작성자: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.author }}

# Discord 알림 - 실패
notify-failure:
runs-on: ubuntu-20.04
needs: [build-and-deploy]
if: failure()
steps:
- name: Discord notification - Failure
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
DISCORD_USERNAME: GitHub
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
uses: Ilshidur/action-discord@master
with:
args: |
❌ ${{ steps.build.outcome == 'failure' && '빌드 중' || '배포 중' }} 오류가 발생했습니다.
❌ ${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && '빌드 중' || '배포 중' }} 오류가 발생했습니다.
브랜치: develop
커밋: ${{ steps.get_commit_info.outputs.message }}
커밋: ${{ needs.build-and-deploy.steps.get_commit_info.outputs.message }}
작성자: <@${{ secrets.DISCORD_ID_1 }}>
실패한 워크플로우: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ steps.build.outcome == 'failure' && '빌드 오류 메시지:' || '' }}
${{ steps.build.outcome == 'failure' && steps.build.outputs.stderr || '' }}

- name: Check deploy result
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
run: exit 1
${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && '빌드 오류 메시지:' || '' }}
${{ needs.build-and-deploy.outputs.build_outcome == 'failure' && needs.build-and-deploy.steps.build_app.outputs.stderr || '' }}
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,21 @@
"overwrite": true,
"format": "ULFO"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": ["darwin"]
},
{
"name": "@electron-forge/maker-deb",
"config": {
"name": "alignlab",
"productDescription": "AlignLab의 데스크톱 애플리케이션"
}
},
{
"name": "@electron-forge/maker-rpm",
"config": {
"name": "alignlab"
}
}
]
],
"publishers": [
{
"name": "@electron-forge/publisher-github",
"config": {
"repository": {
"owner": "DDD-Community",
"name": "DDD-11-HERO-WEB"
},
"draft": false,
"prerelease": false
}
}
]
}
},
"scripts": {
Expand All @@ -63,7 +59,9 @@
"lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
"electron:dev": "concurrently \"yarn dev\" \"cross-env DEV= tsc-watch -p tsconfig.electron.json --onSuccess \\\"electron .\\\"\"",
"electron:preview": "yarn build && tsc -p tsconfig.electron.json && PREVIEW= electron .",
"electron:build": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge make"
"electron:build": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge make",
"electron:publish": "tsc && yarn build && tsc -p tsconfig.electron.json && electron-forge publish"

},
"dependencies": {
"@tanstack/react-query": "^5.51.23",
Expand Down Expand Up @@ -91,6 +89,7 @@
"@electron-forge/maker-squirrel": "^6.0.4",
"@electron-forge/maker-zip": "^6.0.4",
"@electron-forge/maker-dmg": "^6.0.4",
"@electron-forge/publisher-github": "^6.0.4",
"@types/node": "^20.7.1",
"@types/qs": "^6.9.7",
"@types/react": "^18.0.26",
Expand Down
Loading
Loading