Skip to content

Commit

Permalink
Merge pull request #17 from softeerbootcamp4th/build/CLAP-44
Browse files Browse the repository at this point in the history
build(CLAP-44): 어드민 ci/cd 파이프라인 구축
  • Loading branch information
thgee authored Jul 25, 2024
2 parents 7800340 + 5daf186 commit 994076f
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 10 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/fb-hosting-admin-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy Admin to Firebase Hosting on merge
'on':
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
environment: admin-production
defaults:
run:
working-directory: packages/admin
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Make Last Hash
id: last
run: |
LAST_HASH=$(git rev-parse HEAD~:packages/admin)
echo "::set-output name=hash::$LAST_HASH"
- name: Make Current Hash
id: current
run: |
CURRENT_HASH=$(git rev-parse HEAD:packages/admin)
echo "::set-output name=hash::$CURRENT_HASH"
- name: Set Diff
id: diff-check
run: |
if [ "${{ steps.last.outputs.hash }}" != "${{ steps.current.outputs.hash }}" ]; then
echo "::set-output name=diff::true"
else
echo "::set-output name=diff::false"
fi
- name: Create .env file
if: ${{steps.diff-check.outputs.diff == 'true'}}
run: |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$VARS_CONTEXT" > .env
env:
VARS_CONTEXT: ${{ toJson(vars) }}

- name: Install Dependencies and Build
if: ${{steps.diff-check.outputs.diff == 'true'}}
run: |
npm install -g pnpm && pnpm install && pnpm build
- name: Deploy to Firebase Hosting
if: ${{steps.diff-check.outputs.diff == 'true'}}
uses: FirebaseExtended/action-hosting-deploy@v0
with:
target: admin
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WATERMELON_CLAP }}'
projectId: watermelon-clap
channelId: live
68 changes: 68 additions & 0 deletions .github/workflows/fb-hosting-admin-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy Admin to Firebase Hosting on PR
on: pull_request
jobs:


build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
environment: admin-preview
defaults:
run:
working-directory: packages/admin
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Make Last Hash
id: last
run: |
LAST_HASH=$(git rev-parse origin/main:packages/admin)
echo "::set-output name=hash::$LAST_HASH"
- name: Make Current Hash
id: current
run: |
CURRENT_HASH=$(git rev-parse HEAD:packages/admin)
echo "::set-output name=hash::$CURRENT_HASH"
- name: Set Diff
id: diff-check
run: |
if [ "${{ steps.last.outputs.hash }}" != "${{ steps.current.outputs.hash }}" ]; then
echo "::set-output name=diff::true"
else
echo "::set-output name=diff::false"
fi
- name: Create .env file
if: ${{ steps.diff-check.outputs.diff == 'true' }}
run: |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$VARS_CONTEXT" > .env
env:
VARS_CONTEXT: ${{ toJson(vars) }}

- name: Install Dependencies and Build
if: ${{ steps.diff-check.outputs.diff == 'true' }}
run: |
npm install -g pnpm && pnpm install && pnpm build
- name: Deploy to Firebase Hosting
if: ${{ steps.diff-check.outputs.diff == 'true' }}
uses: FirebaseExtended/action-hosting-deploy@v0
id: deploy
with:
disableComment: false
target: admin
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WATERMELON_CLAP }}
projectId: watermelon-clap

- name: Comment PR
if: ${{ steps.diff-check.outputs.diff == 'true'}}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Finish admin deployment!
preview url: ${{ steps.deploy.outputs.details_url}}
expire: ${{ steps.deploy.outputs.expire_time_formatted}}
14 changes: 8 additions & 6 deletions .github/workflows/fb-hosting-service-merge.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy Serivce to Firebase Hosting on merge
name: Deploy Service to Firebase Hosting on merge
'on':
push:
branches:
- main
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
environment: production
environment: service-production
defaults:
run:
working-directory: packages/service
Expand Down Expand Up @@ -41,9 +41,10 @@ jobs:
- name: Create .env file
if: ${{steps.diff-check.outputs.diff == 'true'}}
run: |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$SECRETS_CONTEXT" > .env
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$VARS_CONTEXT" > .env
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
VARS_CONTEXT: ${{ toJson(vars) }}

- name: Install Dependencies and Build
if: ${{steps.diff-check.outputs.diff == 'true'}}
run: |
Expand All @@ -55,4 +56,5 @@ jobs:
target: service
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WATERMELON_CLAP }}'
projectId: watermelon-clap
projectId: watermelon-clap
channelId: live
20 changes: 17 additions & 3 deletions .github/workflows/fb-hosting-service-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
environment: preview
environment: service-preview
defaults:
run:
working-directory: packages/service
Expand Down Expand Up @@ -37,9 +37,9 @@ jobs:
- name: Create .env file
if: ${{ steps.diff-check.outputs.diff == 'true' }}
run: |
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$SECRETS_CONTEXT" > .env
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' <<< "$VARS_CONTEXT" > .env
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
VARS_CONTEXT: ${{ toJson(vars) }}

- name: Install Dependencies and Build
if: ${{ steps.diff-check.outputs.diff == 'true' }}
Expand All @@ -49,8 +49,22 @@ jobs:
- name: Deploy to Firebase Hosting
if: ${{ steps.diff-check.outputs.diff == 'true' }}
uses: FirebaseExtended/action-hosting-deploy@v0
id: deploy
with:
target: service
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WATERMELON_CLAP }}
projectId: watermelon-clap
disableComment: false

- name: Comment PR
if: ${{ steps.diff-check.outputs.diff == 'true'}}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Finish service deployment!
preview url: ${{ steps.deploy.outputs.details_url}}
expire: ${{ steps.deploy.outputs.expire_time_formatted}}

2 changes: 1 addition & 1 deletion packages/admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export const App = () => {
<RouterProvider router={router} />
</GlobalProvider>
);
};
};

0 comments on commit 994076f

Please sign in to comment.