diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e2d0ab9 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,29 @@ +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + run_pull: + name: run pull + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: install ssh keys + # check this thread to understand why its needed: + # https://stackoverflow.com/a/70447517 + run: | + install -m 600 -D /dev/null ~/.ssh/id_rsa + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts + - name: zip repo and deploy + run: | + zip -r server.zip . + scp server.zip ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{secrets.SSH_USER}}/ + ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "./deploy.sh" + - name: cleanup + run: rm -rf ~/.ssh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 290e1fe..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - run_pull: - name: run pull - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: install ssh keys - # check this thread to understand why its needed: - # https://stackoverflow.com/a/70447517 - run: | - install -m 600 -D /dev/null ~/.ssh/id_rsa - echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa - ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts - - name: zip repo and deploy - run: | - zip -r server.zip . - scp server.zip ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{secrets.SSH_USER}}/ - ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "./deploy.sh" - - name: cleanup - run: rm -rf ~/.ssh -