-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
89 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: Dev Server Pull-request # Workflow 이름 | ||
on: | ||
pull_request: #pr이벤트를 감지 | ||
branches: | ||
- dev #dev 브랜치에 한해서 | ||
jobs: # Job 설정 | ||
name: Test Server Merge | ||
on: | ||
push: | ||
branches: [ "test" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -18,32 +18,64 @@ jobs: # Job 설정 | |
|
||
- name: Set .env from secrets | ||
run: | | ||
echo "PORT=${{ secrets.DEV_PORT }}" > .env | ||
echo "PORT=${{ secrets.TEST_PORT }}" > .env | ||
echo "WDS_SOCKET_PORT=0" >> .env | ||
echo "NODE_PATH=src/" >> .env | ||
echo "REACT_APP_API_ROOT=${{ secrets.DEV_REACT_APP_API_ROOT }}" >> .env | ||
echo "REACT_APP_HOME_URL=${{ secrets.DEV_REACT_APP_HOME_URL }}" >> .env | ||
echo "REACT_APP_API_ROOT=${{ secrets.TEST_REACT_APP_API_ROOT }}" >> .env | ||
echo "REACT_APP_HOME_URL=${{ secrets.TEST_REACT_APP_HOME_URL }}" >> .env | ||
- name: cat env file | ||
run: cat .env | ||
|
||
- name: Generate build # React Build | ||
run: npm run build | ||
|
||
- name: Compress build # 압축 | ||
run: tar -czvf build.tar.gz build/ | ||
|
||
- name: Upload compressed build to S3 #압축 파일 올리기 | ||
|
||
- name: file copy | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
path: build | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: file download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build | ||
path: build | ||
- name: Upload to Cloudflare | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-1 | ||
BUCKET_NAME: ${{ secrets.CF_BUCKET_NAME }} | ||
ENDPOINT_URL: ${{ secrets.CF_ENDPOINT_URL }} | ||
run: | | ||
aws s3 cp build.tar.gz s3://$BUCKET_NAME/build.tar.gz \ | ||
aws s3 sync build s3://$BUCKET_NAME/build \ | ||
--endpoint-url $ENDPOINT_URL | ||
- name: SSH and deploy | ||
uses: appleboy/[email protected] | ||
env: | ||
BUCKET_NAME: ${{ secrets.CF_BUCKET_NAME }} | ||
ENDPOINT_URL: ${{ secrets.CF_ENDPOINT_URL }} | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.SSH_KEY }} | ||
port: ${{ secrets.PORT }} | ||
timeout: 40s # 30초 기본 | ||
script: | | ||
aws s3 sync s3://$BUCKET_NAME/build ./docker/react/build \ | ||
--endpoint-url $ENDPOINT_URL | ||
after: | ||
if: always() # Ensures this job always runs after 'build' | ||
needs: deploy | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
|
||
steps: | ||
- name: Discordbot alert # 디스코드 알림 | ||
uses: sarisia/[email protected] | ||
with: | ||
|
@@ -53,4 +85,4 @@ jobs: # Job 설정 | |
(github.actor == 'imi21123' && '<@999337351799128115>') || | ||
(github.actor == 'marina-yhm' && '<@946431150614794240>') || | ||
(github.actor == 'hhhhyelim' && '<@1076887091427946496>') }} | ||
if: always() | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,21 +5,49 @@ on: | |
branches: [ "test" ] | ||
|
||
jobs: | ||
build-and-comment: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- name: Check branch | ||
- name: Checkout source code. # Repo checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check Node v # Node v 확인 | ||
run: node -v | ||
|
||
- name: Install dependencies # 의존 파일 설치 | ||
run: npm install | ||
|
||
- name: Set .env from secrets | ||
run: | | ||
echo "Head branch is: ${{ github.head_ref }}" | ||
echo "Base branch is: ${{ github.base_ref }}" | ||
if [[ "${{ github.head_ref }}" != "dev" ]]; then | ||
echo "dev 브랜치가 아님" | ||
exit 1 | ||
fi | ||
echo "PORT=${{ secrets.TEST_PORT }}" > .env | ||
echo "WDS_SOCKET_PORT=0" >> .env | ||
echo "NODE_PATH=src/" >> .env | ||
echo "REACT_APP_API_ROOT=${{ secrets.TEST_REACT_APP_API_ROOT }}" >> .env | ||
echo "REACT_APP_HOME_URL=${{ secrets.TEST_REACT_APP_HOME_URL }}" >> .env | ||
- name: cat env file | ||
run: cat .env | ||
|
||
- name: Generate build # React Build | ||
run: npm run build | ||
|
||
- name: close PR | ||
if: failure() | ||
after: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
- name: Discordbot alert # 디스코드 알림 | ||
uses: sarisia/[email protected] | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
content: ${{ (github.actor == 'marinesnow34' && '<@392607023495118862>') || | ||
(github.actor == '1223v' && '<@368775981667844098>') || | ||
(github.actor == 'imi21123' && '<@999337351799128115>') || | ||
(github.actor == 'marina-yhm' && '<@946431150614794240>') || | ||
(github.actor == 'hhhhyelim' && '<@1076887091427946496>') }} | ||
if: always() | ||
- name: Comment on failure and close PR | ||
if: needs.build.result == 'failure' | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ github.token }} | ||
|
@@ -28,7 +56,7 @@ jobs: | |
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '브랜치 확인!!' | ||
body: '빌드 실패' | ||
}); | ||
github.rest.pulls.update({ | ||
|
@@ -39,7 +67,7 @@ jobs: | |
}); | ||
- name: Auto approve pull request | ||
if: success() | ||
if: needs.build.result == 'success' | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ github.token }} | ||
|