name: My Gatsby Deployment pipeline run-name: ${{ gitea.actor }} is deploying this page to production. on: push: branches: - master jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 - name: Install dependencies run: npm install --legacy-peer-deps - name: Build Gatsby site run: npx gatsby build env: NODE_ENV: production CI: true - name: Check build output run: | if [ ! -d "public" ]; then echo "Build failed - public directory not found" exit 1 fi - name: Install SSH key uses: shimataro/ssh-key-action@v2 with: key: ${{ secrets.SSH_PRIVATE_KEY }} known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - name: Install rsync run: | sudo apt-get update sudo apt-get install -y rsync - name: Deploy to web server env: DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} run: | rsync -avz -e "ssh -p 2266" \ --exclude='mailadmin/' \ --exclude='postfixadmin/' \ --exclude='roundcube/' \ public/ \ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH - name: Verify deployment env: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} run: | ssh -p 2266 $DEPLOY_USER@$DEPLOY_HOST "test -d $DEPLOY_PATH && echo 'Deployment successful' || (echo 'Deployment failed' && exit 1)"