From afebbb89c2d45af31280aeb52424471062a21f2b Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 3 Nov 2023 11:03:16 +0100 Subject: [PATCH] feat(docker): added workflow for docker compose --- .github/workflows/playground_deployment.yml | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/playground_deployment.yml diff --git a/.github/workflows/playground_deployment.yml b/.github/workflows/playground_deployment.yml new file mode 100644 index 0000000..4f3c06b --- /dev/null +++ b/.github/workflows/playground_deployment.yml @@ -0,0 +1,58 @@ +name: Deploy UVL Playground + +env: + HOSTNAME: 590c9306-8ced-48f6-85f2-bb8caa1bfd52.ul.bw-cloud-instance.org + USERNAME: ubuntu + WORKDIR: /home/ubuntu + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: "npm" + cache-dependency-path: WebSocketClient/UVLPlayground/package-lock.json + - name: Install dependencies + working-directory: WebSocketClient/UVLPlayground + run: npm install + - name: Build + working-directory: WebSocketClient/UVLPlayground + run: npm run build + - name: Install SSH key + run: | + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H $HOSTNAME >> ~/.ssh/known_hosts + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Copy directories to remote server + run: | + scp -r ./WebSocketLanguageServer $USERNAME@$HOSTNAME:$WORKDIR + scp -r ./WebSocketClient/UVLPlayground/dist/ $USERNAME@$HOSTNAME:$WORKDIR/WebSocketClient + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Copy Dockerfile to remote server + run: scp -r ./WebSocketClient/UVLPlayground/Dockerfile $USERNAME@$HOSTNAME:$WORKDIR/WebSocketClient + - name: Run remote script + run: | + ssh -i ~/.ssh/id_rsa $USERNAME@$HOSTNAME 'cd WebSocketLanguageServer && chmod +x ./deployment.sh && ./deployment.sh' + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Run remote script + run: | + ssh -i ~/.ssh/id_rsa $USERNAME@$HOSTNAME 'docker compose up --build -d' + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}