@@ -0,0 +1,138 @@
+name: CI
+
+on:
+  pull_request:
+    types:
+      - closed
+
+env:
+  IMAGE: ${{ vars.NCR_REGISTRY }}/follow-app
+  IMAGE_LATEST: ${{ vars.NCR_REGISTRY }}/follow-app:latest
+
+jobs:
+  lint-test:
+    name: lint and test
+    uses: ./.github/workflows/DRF-test.yaml
+
+  send-discord-fail-message:
+    needs: lint-test
+    if: failure()
+    runs-on: ubuntu-latest
+    steps:
+      - name: Send Message to Discord
+        uses: "hugoalh/send-discord-webhook-ghaction@v5.0.0"
+        with:
+          key: ${{ secrets.DISCORD_WEBHOOK_KEY }}
+          payload: |
+            {
+              "content": "",
+              "embeds": [
+                {
+                  "title": "Test Failed",
+                  "description": "workflow failed at DRF test stage.",
+                  "color": "#b42323",
+                  "footer": {
+                    "text": "${{ github.event_name }}"
+                  }
+                }
+              ],
+              "username": "Project Build Manager",
+              "avatar_url": "https://file.limeskin.kro.kr/curious_cat-small.png",
+            }
+
+  build-and-push:
+    needs: lint-test
+    name: build and push
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: Set up Docker buildx
+        uses: docker/setup-buildx-action@v2
+
+      - name: Login to NCR
+        uses: docker/login-action@v2
+        with:
+          registry: ${{ vars.NCR_REGISTRY }}
+          username: ${{ secrets.NCR_ACCESS_KEY }}
+          password: ${{ secrets.NCR_SECRET_KEY }}
+
+      - name: Get current timestamp
+        id: timestamp
+        run: echo "timestamp=$(date '+%s')" >> "$GITHUB_OUTPUT"
+
+      - name: Build and Push
+        uses: docker/build-push-action@v4
+        with:
+          context: follow_app
+          tags: ${{ env.IMAGE_LATEST }},"${{ env.IMAGE }}:${{ steps.timestamp.outputs.timestamp }}"
+          push: true
+
+  health-check:
+    needs: build-and-push
+    name: health check
+    runs-on: ubuntu-latest
+    steps:
+      - name: Healthcheck Start
+        uses: appleboy/ssh-action@v1.0.0
+        with:
+          host: ${{ secrets.HOST }}
+          username: ${{ secrets.USERNAME }}
+          password: ${{ secrets.PASSWORD }}
+          script: |
+            cd follow_app
+            docker login \
+            ${{ vars.NCR_REGISTRY }} \
+            -u ${{ secrets.NCR_ACCESS_KEY }} \
+            -p ${{ secrets.NCR_SECRET_KEY }}
+            docker pull ${{ env.IMAGE_LATEST }}
+
+  send-discord-fail-health:
+    needs: health-check
+    if: failure()
+    runs-on: ubuntu-latest
+    steps:
+      - name: Send Message to Discord
+        uses: "hugoalh/send-discord-webhook-ghaction@v5.0.0"
+        with:
+          key: ${{ secrets.DISCORD_WEBHOOK_KEY }}
+          payload: |
+            {
+              "content": "",
+              "embeds": [
+                {
+                  "title": "Health Check Failed",
+                  "description": "workflow failed at stage server health check.",
+                  "color": "#b42323",
+                  "footer": {
+                    "text": "${{ github.event_name }}"
+                  }
+                }
+              ],
+              "username": "Project Build Manager",
+              "avatar_url": "https://file.limeskin.kro.kr/curious_cat-small.png",
+            }
+
+  deploy:
+    needs: health-check
+    name: deploy
+    runs-on: ubuntu-latest
+    steps:
+      - name: pull and run image
+        uses: appleboy/ssh-action@v1.0.0
+        with:
+          host: ${{ secrets.HOST }}
+          username: ${{ secrets.USERNAME }}
+          password: ${{ secrets.PASSWORD }}
+          script: |
+            docker login \
+            ${{ vars.NCR_REGISTRY }} \
+            -u ${{ secrets.NCR_ACCESS_KEY }} \
+            -p ${{ secrets.NCR_SECRET_KEY }}
+            docker pull ${{ env.IMAGE_LATEST }}
+            docker stop follow-app
+            docker run -d --rm --name follow-app \
+              --env-file .env \
+              -p 8000:8000 \
+              ${{ env.IMAGE_LATEST }} \
+              /start

리뷰: 다른 yaml 파일에 있는 workflow 를 가져와서 사용하시는거 같은데, 작업 내에 있는 변수도 따로 꺼내서 쓸 수 있나요 ??