From bbfd57319048d906145083724aedd6e35618f5d4 Mon Sep 17 00:00:00 2001 From: jhmin95 Date: Tue, 5 Dec 2023 21:10:18 +0900 Subject: [PATCH] ci: oci-deploy test --- .github/workflows/oci-deploy.yml | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/oci-deploy.yml diff --git a/.github/workflows/oci-deploy.yml b/.github/workflows/oci-deploy.yml new file mode 100644 index 00000000..9abbef17 --- /dev/null +++ b/.github/workflows/oci-deploy.yml @@ -0,0 +1,72 @@ +name: Deploy to OCI + +on: + push: + branches: + - oci-deploy-test + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Cache node modules # node modules 캐싱 + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.OS }}-master-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build- + ${{ runner.OS }}- + - name: Generate Environment Variables File for Production + run: | + echo "REACT_APP_API=$REACT_APP_API" >> .env + echo "REACT_APP_WISH=$REACT_APP_WISH" >> .env + echo "REACT_APP_E_BOOK_LIBRARY=$REACT_APP_E_BOOK_LIBRARY" >> .env + echo "REACT_APP_SUGGESTION=$REACT_APP_SUGGESTION" >> .env + echo "REACT_APP_GA_ID=$REACT_APP_GA_ID" >> .env + echo "PORT=$PORT" >> .env + env: + REACT_APP_API: ${{ secrets.REACT_APP_API }} + REACT_APP_WISH: ${{ secrets.REACT_APP_WISH }} + REACT_APP_E_BOOK_LIBRARY: ${{ secrets.REACT_APP_E_BOOK_LIBRARY }} + REACT_APP_SUGGESTION: ${{ secrets.REACT_APP_SUGGESTION }} + REACT_APP_GA_ID: ${{ secrets.REACT_APP_GA_ID }} + PORT: ${{ secrets.PORT }} + + - name: Install Pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.x + + - name: Install Dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Deploy to OCI + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.OCI_IP }} + username: ${{ secrets.OCI_USER }} + key: ${{ secrets.OCI_KEY }} + port: ${{ secrets.OCI_PORT }} + script: | + cd /home/opc/frontend + echo "REACT_APP_API=${{ secrets.REACT_APP_API }} + REACT_APP_WISH=${{ secrets.REACT_APP_WISH }} + REACT_APP_E_BOOK_LIBRARY=${{ secrets.REACT_APP_E_BOOK_LIBRARY }} + REACT_APP_SUGGESTION=${{ secrets.REACT_APP_SUGGESTION }} + REACT_APP_GA_ID=${{ secrets.REACT_APP_GA_ID }} + PORT=${{ secrets.PORT }} + " > .env + git pull + cd client + pnpm install + pnpm run build + mv build ../backend/ + rm .env