diff --git a/.gitea/workflows/website-sync.yaml b/.gitea/workflows/website-sync.yaml index c803483..6ca2f62 100644 --- a/.gitea/workflows/website-sync.yaml +++ b/.gitea/workflows/website-sync.yaml @@ -7,9 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Setup SSH agent and deploy + - name: Setup SSH agent and deploy to web + if: GITHUB_REF_NAME == 'main' run: | eval "$(ssh-agent -s)" mkdir -p ~/.ssh @@ -23,4 +24,21 @@ jobs: SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} SSH_USER: ${{ secrets.SSH_USER }} SSH_HOST: ${{ secrets.SSH_HOST }} - SSH_WEBSITE_LOCATION: ${{ secrets.SSH_WEBSITE_LOCATION }} \ No newline at end of file + SSH_WEBSITE_LOCATION: ${{ secrets.SSH_WEBSITE_LOCATION }} + + - name: Setup SSH agent and deploy to development + if: GITHUB_REF_NAME == 'development' + run: | + eval "$(ssh-agent -s)" + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + chmod 700 ~/.ssh + ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts + + ssh "$SSH_USER@$SSH_HOST" "cd $SSH_WEBSITE_LOCATION && git stash && git pull --force origin development" + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_USER: ${{ secrets.SSH_USER }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_WEBSITE_LOCATION: ${{ secrets.SSH_WEBSITE_LOCATION_DEVELOPMENT }} \ No newline at end of file