[Refactor] SSE 훅을 Provider로 통합, unReadCount 전역상태에서 제거 #314
Workflow file for this run
This file contains hidden or 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
| name: Cleanup Preview to EC2 | |
| on: | |
| pull_request: | |
| types: [closed] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: preview-${{ github.head_ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| cleanup-preview: | |
| runs-on: ubuntu-latest | |
| env: | |
| SCRIPTS_DIR: /home/ubuntu/scripts/ec2 | |
| CLEANUP_SCRIPT: ec2-cleanup.sh | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Compute branch name & port | |
| id: meta | |
| run: | | |
| RAW="${{ github.head_ref }}" | |
| SANITIZED="$(echo "$RAW" | tr '[:upper:]' '[:lower:]' | sed 's#[^a-z0-9._-]#-#g')" | |
| PORT=$(( 5000 + $(echo -n "$SANITIZED" | cksum | awk '{print $1 % 1000}') )) | |
| echo "app_dir=preview-$SANITIZED" >> $GITHUB_OUTPUT | |
| echo "branch=$SANITIZED" >> $GITHUB_OUTPUT | |
| echo "app_port=$PORT" >> $GITHUB_OUTPUT | |
| echo "pm2_app_name=preview-$SANITIZED" >> $GITHUB_OUTPUT | |
| echo "[DEBUG][META] ✅ RAW=$RAW" | |
| echo "[DEBUG][META] ✅ SANITIZED=$SANITIZED" | |
| echo "[DEBUG][META] ✅ APP_DIR=preview-$SANITIZED" | |
| echo "[DEBUG][META] ✅ BRANCH=$SANITIZED" | |
| echo "[DEBUG][META] ✅ APP_PORT=$PORT" | |
| echo "[DEBUG][META] ✅ PM2_APP_NAME=preview-$SANITIZED" | |
| - name: Send Cleanup Script to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.AWS_EC2_HOST }} | |
| username: ${{ secrets.AWS_EC2_USERNAME }} | |
| key: ${{ secrets.AWS_EC2_PEM_KEY }} | |
| source: scripts/ec2/ec2-cleanup.sh | |
| target: /home/ubuntu/ | |
| - name: Cleanup Preview Environment | |
| uses: appleboy/ssh-action@v1 | |
| env: | |
| APP_DIR: ${{ steps.meta.outputs.app_dir }} | |
| PM2_APP_NAME: ${{ steps.meta.outputs.pm2_app_name }} | |
| BRANCH: ${{ steps.meta.outputs.branch }} | |
| with: | |
| host: ${{ secrets.AWS_EC2_HOST }} | |
| username: ${{ secrets.AWS_EC2_USERNAME }} | |
| key: ${{ secrets.AWS_EC2_PEM_KEY }} | |
| envs: APP_DIR,PM2_APP_NAME,BRANCH,SCRIPTS_DIR,CLEANUP_SCRIPT | |
| script: | | |
| chmod +x $SCRIPTS_DIR/$CLEANUP_SCRIPT | |
| $SCRIPTS_DIR/$CLEANUP_SCRIPT "$APP_DIR" "$PM2_APP_NAME" "$BRANCH" |