diff --git a/scaffold/github/workflows/PantheonReviewAppsManual.yml b/scaffold/github/workflows/PantheonReviewAppsManual.yml new file mode 100644 index 00000000..8d4f2746 --- /dev/null +++ b/scaffold/github/workflows/PantheonReviewAppsManual.yml @@ -0,0 +1,72 @@ +name: "Pantheon Review Apps" + +on: + pull_request: + types: [ labeled, opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +# You will also need to add the secrets used below to Dependabot secrets +# if you want this to successfully run in auto-created PRs. +permissions: + deployments: write + contents: read + pull-requests: read + +jobs: + Drainpipe-Deploy-Pantheon-Multidev: + if: contains(github.event.pull_request.labels.*.name, 'pantheon-multidev') + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - uses: ./.github/actions/drainpipe/set-env + + - uses: ./.github/actions/drainpipe/setup-git + with: + git-name: Drainpipe Bot + git-email: no-reply@example.com + + - uses: ./.github/actions/drainpipe/setup-ssh + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} + + - uses: ./.github/actions/drainpipe/pantheon/setup-terminus + with: + pantheon-token: ${{ secrets.PANTHEON_TERMINUS_TOKEN }} + terminus-plugins: ${{ vars.TERMINUS_PLUGINS || secrets.TERMINUS_PLUGINS }} + + - uses: php-actions/composer@v6 + + - name: Build Project + env: + directory: /tmp/release + run: | + composer install + task build + task snapshot:directory directory=/tmp/release + + - name: Deploy Pantheon Review App + uses: ./.github/actions/drainpipe/pantheon/review + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + terminus-token: ${{ secrets.PANTHEON_TERMINUS_TOKEN }} + commit-message: ${{ github.sha }} + site-name: ${{ vars.PANTHEON_SITE_NAME || secrets.PANTHEON_SITE_NAME }} + lock-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + lock-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} diff --git a/scaffold/github/workflows/PantheonReviewAppsManualDDEV.yml b/scaffold/github/workflows/PantheonReviewAppsManualDDEV.yml new file mode 100644 index 00000000..142c5aca --- /dev/null +++ b/scaffold/github/workflows/PantheonReviewAppsManualDDEV.yml @@ -0,0 +1,52 @@ +name: "Pantheon Review Apps" + +on: + pull_request: + types: [ labeled, unlabeled, opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + Drainpipe-Deploy-Pantheon-Multidev: + if: contains(github.event.pull_request.labels.*.name, 'pantheon-multidev') + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.ddev/.drainpipe-composer-cache + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - uses: ./.github/actions/drainpipe/set-env + + - name: Install and Start DDEV + uses: ./.github/actions/drainpipe/ddev + with: + git-name: Drainpipe Bot + git-email: no-reply@example.com + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} + + - name: Build Project + env: + directory: /tmp/release + run: | + ddev composer install + ddev task build + ddev task snapshot:directory directory=/tmp/release + + - name: Deploy Pantheon Review App + uses: ./.github/actions/drainpipe/pantheon/review + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + terminus-token: ${{ secrets.PANTHEON_TERMINUS_TOKEN }} + commit-message: ${{ github.sha }} + site-name: ${{ vars.PANTHEON_SITE_NAME || secrets.PANTHEON_SITE_NAME }} + lock-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + lock-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + # set to "true" if you want to run the installer + run-installer: ${{ secrets.PANTHEON_REVIEW_RUN_INSTALLER }} diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 21b5b2ef..816daaf7 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -322,15 +322,17 @@ private function installGitHubActions(string $scaffoldPath): void { $fs->ensureDirectoryExists('./.github/actions'); $fs->copy("$scaffoldPath/github/actions/common", './.github/actions/drainpipe'); foreach ($this->extra['drainpipe']['github'] as $github) { - if ($github === 'PantheonReviewApps') { + if ($github === 'PantheonReviewApps' || $github === 'PantheonReviewAppsManual') { $fs->ensureDirectoryExists('./.github/actions/drainpipe/pantheon'); $fs->ensureDirectoryExists('./.github/workflows'); $fs->copy("$scaffoldPath/github/actions/pantheon", './.github/actions/drainpipe/pantheon'); + $pantheon_review_apps = ($github === 'PantheonReviewApps') ? 'PantheonReviewApps' : 'PantheonReviewAppsManual'; if (file_exists('./.ddev/config.yaml')) { - $fs->copy("$scaffoldPath/github/workflows/PantheonReviewAppsDDEV.yml", './.github/workflows/PantheonReviewApps.yml'); + $pantheon_review_apps_ddev = $pantheon_review_apps . 'DDEV'; + $fs->copy("$scaffoldPath/github/workflows/$pantheon_review_apps_ddev.yml", './.github/workflows/PantheonReviewApps.yml'); } else { - $fs->copy("$scaffoldPath/github/workflows/PantheonReviewApps.yml", './.github/workflows/PantheonReviewApps.yml'); + $fs->copy("$scaffoldPath/github/workflows/$pantheon_review_apps.yml", './.github/workflows/PantheonReviewApps.yml'); } } else if ($github === 'ComposerLockDiff') {