|
| 1 | +name: Deploy to Pantheon |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + deploy: |
| 10 | + if: ${{ vars.DEPLOY_TO_PANTHEON }} |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + node-version: [18.x] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v3 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + |
| 26 | + - name: Install npm dependencies |
| 27 | + run: npm ci |
| 28 | + |
| 29 | + - name: Install PHP dependencies with Composer |
| 30 | + uses: php-actions/composer@v6 |
| 31 | + with: |
| 32 | + php_version: '8.1' |
| 33 | + version: 2.x |
| 34 | + |
| 35 | + - name: Build theme |
| 36 | + run: npm run build:prod |
| 37 | + |
| 38 | + - name: Install SSH key |
| 39 | + uses: shimataro/ssh-key-action@v2 |
| 40 | + with: |
| 41 | + key: ${{ secrets.PANTHEON_ID_RSA }} |
| 42 | + known_hosts: ${{ secrets.KNOWN_HOSTS }} |
| 43 | + |
| 44 | + - name: Add SSH Key |
| 45 | + run: | |
| 46 | + eval `ssh-agent` |
| 47 | + ssh-add ~/.ssh/id_rsa |
| 48 | +
|
| 49 | + - name: Checkout Pantheon remote |
| 50 | + run: | |
| 51 | + git config --global user.email "${{ secrets.PRODUCTION_USER_EMAIL }}" |
| 52 | + git config --global user.name "${{ secrets.PRODUCTION_USER_NAME }}" |
| 53 | + git remote add pantheon ${{ secrets.PRODUCTION_REPO }} |
| 54 | + git fetch pantheon master |
| 55 | + git worktree add --track -b prod prod pantheon/master |
| 56 | +
|
| 57 | + - name: Copy build artifacts |
| 58 | + run: | |
| 59 | + rm -rf prod/vendor prod/wp-content/plugins prod/wp-content/themes/sparkpress |
| 60 | + cp -r vendor prod |
| 61 | + cp -r theme prod/wp-content/themes/sparkpress |
| 62 | + cp -r wp-content/plugins prod/wp-content/plugins |
| 63 | +
|
| 64 | + - name: Deploy to Pantheon |
| 65 | + run: | |
| 66 | + cd prod |
| 67 | + git status |
| 68 | + git add . |
| 69 | + git commit -m "Prod release" |
| 70 | + git push pantheon HEAD:master |
0 commit comments