From a06ade3753369ed339199a03aff71ee7b1f382d8 Mon Sep 17 00:00:00 2001 From: Mahdi Khanzadi Date: Thu, 26 Sep 2024 09:12:59 +0200 Subject: [PATCH] introduce reactjs branch ci/cd --- .github/workflows/liara-reactjs.yaml | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/liara-reactjs.yaml diff --git a/.github/workflows/liara-reactjs.yaml b/.github/workflows/liara-reactjs.yaml new file mode 100644 index 00000000..0304f29f --- /dev/null +++ b/.github/workflows/liara-reactjs.yaml @@ -0,0 +1,69 @@ +name: CI and CD +on: + push: + branches: + - reactjs +jobs: + ci-backend: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + + - name: Run unit tests + run: | + cd ./backend && go test ./... -v -race -cover + + cd-backend: + runs-on: ubuntu-latest + + needs: + - ci-backend + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: "reactjs" + + - uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: deploy to production + env: + LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }} + LIARA_BACKEND_APP_NAME: ${{secrets.LIARA_BACKEND_APP_NAME_REACTJS}} + LIARA_FRONTEND_APP_NAME: ${{secrets.LIARA_FRONTEND_APP_NAME_REACTJS}} + run: | + npm i -g @liara/cli@5 + cd ./backend && liara deploy --platform=docker --port="80" --app="$LIARA_BACKEND_APP_NAME" --api-token="$LIARA_TOKEN" --detach + + cd-frontend: + runs-on: ubuntu-latest + + needs: + - cd-backend + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - uses: actions/setup-node@v3 + with: + node-version: "18" + + - name: deploy to production + env: + LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }} + LIARA_BACKEND_APP_NAME: ${{secrets.LIARA_BACKEND_APP_NAME_REACTJS}} + LIARA_FRONTEND_APP_NAME: ${{secrets.LIARA_FRONTEND_APP_NAME_REACTJS}} + run: | + npm i -g @liara/cli@5 + cd ./frontend && liara deploy --platform=docker --port="3000" --app="$LIARA_FRONTEND_APP_NAME" --api-token="$LIARA_TOKEN" --detach