Skip to content

Commit

Permalink
Issue #535: Use labels to run the Multidev deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
leonel-lullabot committed Apr 29, 2024
1 parent 8801947 commit ddd39f7
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
52 changes: 52 additions & 0 deletions scaffold/github/workflows/PantheonReviewAppsDDEVManual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Pantheon Review Apps"

on:
pull_request_target:
types: [ ready_for_review, labeled ]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Drainpipe-Deploy-Pantheon-Multidev:
runs-on: ubuntu-22.04
if: github.event.label.name == 'pantheon-multidev'
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: [email protected]
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 }}
72 changes: 72 additions & 0 deletions scaffold/github/workflows/PantheonReviewAppsManual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "Pantheon Review Apps"

on:
pull_request_target:
types: [ ready_for_review, labeled ]

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:
runs-on: ubuntu-22.04
if: github.event.label.name == 'pantheon-multidev'
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: [email protected]

- 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 }}
11 changes: 11 additions & 0 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ private function installCICommands(): void
$fs->copy("$scaffoldPath/github/workflows/PantheonReviewApps.yml", './.github/workflows/PantheonReviewApps.yml');
}
}
elseif ($github === 'PantheonReviewAppsManual') {
$fs->ensureDirectoryExists('./.github/actions/drainpipe/pantheon');
$fs->ensureDirectoryExists('./.github/workflows');
$fs->copy("$scaffoldPath/github/actions/pantheon", './.github/actions/drainpipe/pantheon');
if (file_exists('./.ddev/config.yaml')) {
$fs->copy("$scaffoldPath/github/workflows/PantheonReviewAppsDDEVManual.yml", './.github/workflows/PantheonReviewApps.yml');
}
else {
$fs->copy("$scaffoldPath/github/workflows/PantheonReviewAppsManual.yml", './.github/workflows/PantheonReviewApps.yml');
}
}
else if ($github === 'ComposerLockDiff') {
$fs->ensureDirectoryExists('./.github/workflows');
$fs->copy("$scaffoldPath/github/workflows/ComposerLockDiff.yml", './.github/workflows/ComposerLockDiff.yml');
Expand Down

0 comments on commit ddd39f7

Please sign in to comment.