diff --git a/.github/workflows/deploy.pantheon.yml b/.github/workflows/deploy.pantheon.git.yml similarity index 79% rename from .github/workflows/deploy.pantheon.yml rename to .github/workflows/deploy.pantheon.git.yml index 018d4d9..e657ec2 100644 --- a/.github/workflows/deploy.pantheon.yml +++ b/.github/workflows/deploy.pantheon.git.yml @@ -1,4 +1,4 @@ -name: Deploy to Pantheon +name: Deploy to Pantheon (Git) on: push: @@ -7,7 +7,7 @@ on: jobs: deploy: - if: ${{ vars.DEPLOY_TO_PANTHEON_GIT || vars.DEPLOY_TO_PANTHEON_SFTP }} + if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }} runs-on: ubuntu-latest strategy: @@ -46,9 +46,7 @@ jobs: eval `ssh-agent` ssh-add ~/.ssh/id_rsa - # Git-specific deployment steps - name: Checkout Pantheon remote - if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }} run: | git config --global user.email "${{ secrets.PRODUCTION_USER_EMAIL }}" git config --global user.name "${{ secrets.PRODUCTION_USER_NAME }}" @@ -57,7 +55,6 @@ jobs: git worktree add --track -b prod prod pantheon/master - name: Copy build artifacts - if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }} run: | rm -rf prod/vendor prod/wp-content/plugins prod/wp-content/themes/sparkpress cp -r vendor prod @@ -66,17 +63,10 @@ jobs: mkdir -p wp-content/plugins cp -r wp-content/plugins prod/wp-content/plugins - - name: Deploy to Pantheon via Git - if: ${{ vars.DEPLOY_TO_PANTHEON_GIT }} + - name: Deploy to Pantheon run: | cd prod git status | grep "nothing to commit" && exit 0 || git status git add . git commit -m "Prod release" git push pantheon HEAD:master - - # SFTP-specific deployment steps - - name: Deploy to Pantheon via SFTP - if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }} - run: | - echo "This is a test" diff --git a/.github/workflows/deploy.pantheon.sftp.yml b/.github/workflows/deploy.pantheon.sftp.yml new file mode 100644 index 0000000..50eee50 --- /dev/null +++ b/.github/workflows/deploy.pantheon.sftp.yml @@ -0,0 +1,52 @@ +name: Deploy to Pantheon (SFTP) + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + deploy: + if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }} + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install npm dependencies + run: npm ci + + - name: Install PHP dependencies with Composer + uses: php-actions/composer@v6 + with: + php_version: '8.1' + version: 2.x + + - name: Build theme + run: npm run build:prod + + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.PANTHEON_ID_RSA }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + + - name: Add SSH Key + run: | + eval `ssh-agent` + ssh-add ~/.ssh/id_rsa + + - name: Deploy to Pantheon via SFTP + if: ${{ vars.DEPLOY_TO_PANTHEON_SFTP }} + run: | + echo "This is a test"