diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4d81beb..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -on: push -name: Release -jobs: - release: - name: Release - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' - steps: - - name: Install - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - run: npm i - - - name: Build - id: build - run: npm run build - env: - supabase: ${{ secrets.supabase }} - - name: Docs - env: - supabase: ${{ github.secrets.supabase }} - id: build - run: npm run build - - name: Deploy - uses: JamesIves/github-pages-deploy-action@releases/v3 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_KEY }} - BRANCH: gh-pages - FOLDER: docs/.vuepress/dist diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c34f053 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,61 @@ +name: Deploy + +on: + pull_request: + branches: + - main + +env: + PUBLIC: "~/motsflex/public" + ASSETS: "$PUBLIC/assets" + INDEX_HTML: "$PUBLIC/index.html" + DICOS: "~/dicos" + SERVER: "~/motsflex/server.js" + SSH_TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "16" + + - name: Install Dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Check deployement type + id: deployment_type + run: | + echo "::set-output name=deploy_assets::${{ contains(github.event.pull_request.labels.*.name, 'deploy:assets') }}" + echo "::set-output name=deploy_server::${{ contains(github.event.pull_request.labels.*.name, 'deploy:server') }}" + echo "::set-output name=deploy_client::${{ contains(github.event.pull_request.labels.*.name, 'deploy:client') }}" + + - name: Deploy + if: steps.determine_deployment.outputs.deployment_type == 'tags' + run: | + echo "Github resfs: $GITHUB_REF" + if [[ steps.deployment_type.outputs.deploy_assets == 'true' ]]; then + echo "Deploying JS assets" + ssh $SSH_TARGET "rm -rf $ASSETS && mkdir -p $ASSETS" + scp -r dist/public/assets $SSH_TARGET:$ASSETS + scp -r dist/public/index.html $SSH_TARGET:$INDEX_HTML + fi + if [[ steps.deployment_type.outputs.deploy_client == 'true' ]]; then + echo "Deploying full client" + ssh $SSH_TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC" + scp -r dist/public $SSH_TARGET:$PUBLIC + ssh $SSH_TARGET "cp $DICOS/*.zip $ASSETS" + fi + if [[ steps.deployment_type.outputs.deploy_server == 'true' ]]; then + echo "Deploying server code" + scp -r dist/server.js $SSH_TARGET:$SERVER + fi