From a01dbb918e6fdca02ac6d70534ebc54d08eb4cb6 Mon Sep 17 00:00:00 2001 From: codinghack0810 Date: Thu, 29 Aug 2024 06:45:49 +1000 Subject: [PATCH] set workflow --- .github/workflows/workflow.yml | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..79c081a --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,37 @@ +name: CI/CD Pipeline + +# Controls when the action will run. Triggers the workflow on push events but only for the main branch +on: + push: + branches: + - main # Change this to your deployment branch + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + # Add additional steps here to install dependencies, run tests, etc. + + - name: Deploy + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + run: | + echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + mkdir -p ~/.ssh + touch ~/.ssh/known_hosts + ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts + ssh $SSH_USER@$SSH_HOST << 'EOF' + cd /path/to/your/application # Change this to your application's path on the server + git pull origin main # Ensure you're pulling the right branch, e.g., `main` + # Add commands to restart your service/application if necessary + # Example for Node.js with PM2: + npm install + pm2 restart app_name + EOF