|
| 1 | +name: Build and Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: deploy |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_deploy: |
| 14 | + name: Build and Deploy |
| 15 | + runs-on: ubuntu-latest |
| 16 | + env: |
| 17 | + SSH_AUTH_SOCK: /tmp/ssh_agent.sock |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup SSH key and known_hosts |
| 23 | + run: | |
| 24 | + mkdir -p -m 700 ~/.ssh |
| 25 | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null |
| 26 | + ssh-add - <<< "${{ secrets.DEPLOY_KEY }}" |
| 27 | + ssh-keyscan ${{ secrets.DEPLOY_TARGET }} >> ~/.ssh/known_hosts |
| 28 | + ssh-keyscan ${{ secrets.DEPLOY_KIT_TARGET }} >> ~/.ssh/known_hosts |
| 29 | +
|
| 30 | + - name: Use Node.js 20 |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 20 |
| 34 | + |
| 35 | + # Set up composer caching |
| 36 | + - name: Cache Composer dependencies |
| 37 | + uses: actions/cache@v4 |
| 38 | + with: |
| 39 | + path: /tmp/composer-cache |
| 40 | + key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} |
| 41 | + |
| 42 | + # Build Parts Kit Plugin |
| 43 | + - name: Build Parts Kit plugin |
| 44 | + run: | |
| 45 | + npm ci |
| 46 | + npm run build |
| 47 | + working-directory: wp-content/plugins/viget-parts-kit |
| 48 | + |
| 49 | + # Deploy code |
| 50 | + - name: Deploy Sandbox |
| 51 | + run: | |
| 52 | +
|
| 53 | + ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }} "\ |
| 54 | + sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\ |
| 55 | + sudo rm -rf ${{ secrets.APP_PATH }}/wp-content/plugins/viget-parts-kit &&\ |
| 56 | + rsync -rlptzv --exclude="node_modules" ./wp-content/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }}:${{ secrets.APP_PATH }}/wp-content/ |
| 57 | + ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_TARGET }} "\ |
| 58 | + sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\ |
| 59 | + sudo chown -R ${{ secrets.DEPLOY_DAEMON }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content/plugins" |
| 60 | +
|
| 61 | + - name: Deploy Parts Kit |
| 62 | + run: | |
| 63 | +
|
| 64 | + ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }} "\ |
| 65 | + sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\ |
| 66 | + sudo rm -rf ${{ secrets.APP_PATH }}/wp-content/plugins/viget-parts-kit &&\ |
| 67 | + rsync -rlptzv --exclude="node_modules" ./wp-content/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }}:${{ secrets.APP_PATH }}/wp-content/ |
| 68 | + ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_KIT_TARGET }} "\ |
| 69 | + sudo chown -R ${{ secrets.DEPLOY_USER }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content &&\ |
| 70 | + sudo chown -R ${{ secrets.DEPLOY_DAEMON }}:${{ secrets.DEPLOY_DAEMON }} ${{ secrets.APP_PATH }}/wp-content/plugins" |
0 commit comments