From 1ce6e34100d9f911211cb7a96196d4f91427ddf7 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Thu, 22 Feb 2024 10:31:47 +0000 Subject: [PATCH 01/14] Issue #204: Add a task for fetching a database from Acquia --- README.md | 12 ++++++++++++ tasks/acquia.yml | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tasks/acquia.yml diff --git a/README.md b/README.md index 613e8475e..87c8d4463 100644 --- a/README.md +++ b/README.md @@ -369,6 +369,18 @@ includes: See below for CI specific integrations for hosting providers. +### Acquia +Acquia specific tasks are contained in [`tasks/pantheon.yml`](tasks/pantheon.yml). +Add the following to your `Taskfile.yml`'s `includes` section to use them: +```yml +includes: + acquia: ./vendor/lullabot/drainpipe/tasks/acquia.yml +``` +| | | +|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `task acquia:fetch-db` | Fetches a database from Pantheon. Set `ACQUIA_ENVIRONMENT_ID` in Taskfile `vars`, along with `ACQUIA_API_KEY` and `ACQUIA_API_SECRET` as environment variables | + + ## GitHub Actions Integration Add the following to `composer.json` for generic GitHub Actions that will be diff --git a/tasks/acquia.yml b/tasks/acquia.yml new file mode 100644 index 000000000..06430563b --- /dev/null +++ b/tasks/acquia.yml @@ -0,0 +1,19 @@ +version: '3' + +tasks: + fetch-db: + desc: "Fetches a database from Acquia" + env: + DB_DIR: '{{default "/var/www/html/files/db" .DB_DIR}}' + cmds: + - mkdir -p $DB_DIR + - rm -f $DB_DIR/db.sql.gz $DB_DIR/db.sql + - if [ -z "$ACQUIA_API_KEY" ]; then echo "ACQUIA_API_KEY is empty, please add it to your .env file"; exit 1; fi + - if [ -z "$ACQUIA_API_SECRET" ]; then echo "ACQUIA_API_SECRET is empty, please add it to your .env file"; exit 1; fi + - echo "💧 Authorising with Acquia" + - acli auth:login --no-interaction --key=${ACQUIA_API_KEY} --secret=${ACQUIA_API_SECRET} + - echo "💧 Fetching database from Acquia" + - acli pull:database {{.ACQUIA_ENVIRONMENT_ID}} default --no-import --no-interaction + - | + DB=$(ls -t /tmp/*.sql.gz | head -1) + mv $DB $DB_DIR/db.sql.gz From 6118b7a7aa9f41e9ff62e4af85678065b2d9f520 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Fri, 1 Mar 2024 12:15:25 +0000 Subject: [PATCH 02/14] Allow the db name to be customised --- tasks/acquia.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/acquia.yml b/tasks/acquia.yml index 06430563b..50df8c1ce 100644 --- a/tasks/acquia.yml +++ b/tasks/acquia.yml @@ -5,6 +5,7 @@ tasks: desc: "Fetches a database from Acquia" env: DB_DIR: '{{default "/var/www/html/files/db" .DB_DIR}}' + DB_NAME: '{{default "default" .DB_NAME}}' cmds: - mkdir -p $DB_DIR - rm -f $DB_DIR/db.sql.gz $DB_DIR/db.sql @@ -13,7 +14,7 @@ tasks: - echo "💧 Authorising with Acquia" - acli auth:login --no-interaction --key=${ACQUIA_API_KEY} --secret=${ACQUIA_API_SECRET} - echo "💧 Fetching database from Acquia" - - acli pull:database {{.ACQUIA_ENVIRONMENT_ID}} default --no-import --no-interaction + - acli pull:database {{.ACQUIA_ENVIRONMENT_ID}} $DB_NAME --no-import --no-interaction - | DB=$(ls -t /tmp/*.sql.gz | head -1) mv $DB $DB_DIR/db.sql.gz From a67e79f105416f6a05dbf2c5a1317ebe540750fd Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 5 Mar 2024 14:57:07 +0000 Subject: [PATCH 03/14] Add GitHub Actions for Acquia --- .github/workflows/TestAcquia.yml | 90 +++++++++++++++++++ README.md | 14 ++- scaffold/acquia/.drainpipeignore | 3 + scaffold/acquia/settings.acquia.php | 70 +++++++++++++++ .../actions/acquia/clone-env/action.yml | 24 +++++ .../github/actions/acquia/deploy/action.yml | 69 ++++++++++++++ .../github/actions/acquia/push/action.yml | 35 ++++++++ .../github/actions/acquia/update/action.yml | 27 ++++++ .../common/deployment-create/action.yml | 28 ++++++ .../common/deployment-status/action.yml | 24 +++++ src/ScaffoldInstallerPlugin.php | 27 ++++++ tasks/acquia.yml | 11 ++- 12 files changed, 417 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/TestAcquia.yml create mode 100644 scaffold/acquia/.drainpipeignore create mode 100644 scaffold/acquia/settings.acquia.php create mode 100644 scaffold/github/actions/acquia/clone-env/action.yml create mode 100644 scaffold/github/actions/acquia/deploy/action.yml create mode 100644 scaffold/github/actions/acquia/push/action.yml create mode 100644 scaffold/github/actions/acquia/update/action.yml create mode 100644 scaffold/github/actions/common/deployment-create/action.yml create mode 100644 scaffold/github/actions/common/deployment-status/action.yml diff --git a/.github/workflows/TestAcquia.yml b/.github/workflows/TestAcquia.yml new file mode 100644 index 000000000..b0c5a6ef1 --- /dev/null +++ b/.github/workflows/TestAcquia.yml @@ -0,0 +1,90 @@ +name: "Test Acquia" + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: development + +jobs: + Test-Pantheon: + runs-on: ubuntu-22.04 + steps: + - name: Create a Drupal project + run: composer create-project drupal/recommended-project . --ignore-platform-req=ext-gd + + - uses: actions/checkout@v4 + with: + path: drainpipe + + - uses: ./drainpipe/scaffold/github/actions/common/set-env + + - name: Install DDEV + uses: ./drainpipe/scaffold/github/actions/common/ddev + with: + git-name: Drainpipe Bot + git-email: no-reply@example.com + ssh-private-key: ${{ secrets.ACQUIA_SSH_PRIVATE_KEY }} + + - name: Setup Project + run: | + ddev config --auto + ddev start + ddev composer config extra.drupal-scaffold.gitignore true + ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"] + ddev composer config --no-plugins allow-plugins.composer/installers true + ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true + ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true + ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' + ddev composer config extra.drainpipe.acquia --json '{"settings": true, "github": []}' + ddev composer config minimum-stability dev + ddev composer require lullabot/drainpipe --with-all-dependencies + + - name: Install Drupal + run: | + ddev drush site:install minimal -y + echo "\$settings['config_sync_directory'] = '../config';" >> web/sites/default/settings.php + ddev drush config:export -y + + - name: Create .drainpipeignore + run: | + echo "/web/sites/default/files" >> .drainpipeignore + echo "/.ddev" >> .drainpipeignore + echo "settings.ddev.php" >> .drainpipeignore + echo "/drainpipe" >> .drainpipeignore + + - name: Create settings.php + run: | + echo ' web/sites/default/settings.php + echo "\$settings['container_yamls'][] = __DIR__ . '/services.yml';" >> web/sites/default/settings.php + echo "include __DIR__ . \"/settings.acquia.php\";" >> web/sites/default/settings.php + echo "\$settings['config_sync_directory'] = '../config';" >> web/sites/default/settings.php + + - name: Snapshot Project + env: + directory: /tmp/release + remote: + message: + site: + run: | + echo "/drainpipe" >> .drainpipeignore + ddev task snapshot:directory directory=/tmp/release + + - name: Clone from production to dev + uses: ./drainpipe/scaffold/github/actions/acquia/clone-env + with: + source-environment: lullabotsandbox.prod + target-environment: lullabotsandbox.dev + api-key: ${{ secrets.ACQUIA_API_KEY }} + api-secret: ${{ secrets.ACQUIA_API_SECRET }} + + - name: Deploy to dev + uses: ./drainpipe/scaffold/github/actions/acquia/deploy + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + environment: lullabotsandbox.dev + environment-url: https://lullabotsandboxffi2ugpgwh.devcloud.acquia-sites.com + run-installer: true + commit-message: ${{ github.sha }} + api-key: ${{ secrets.ACQUIA_API_KEY }} + api-secret: ${{ secrets.ACQUIA_API_SECRET }} diff --git a/README.md b/README.md index 87c8d4463..e33b0581e 100644 --- a/README.md +++ b/README.md @@ -380,6 +380,16 @@ includes: |------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | `task acquia:fetch-db` | Fetches a database from Pantheon. Set `ACQUIA_ENVIRONMENT_ID` in Taskfile `vars`, along with `ACQUIA_API_KEY` and `ACQUIA_API_SECRET` as environment variables | +To enable auto configuration of Acquia Cloud settings: +```json +"extra": { + "drainpipe": { + "acquia": { + "settings": true + }, + } +} +``` ## GitHub Actions Integration @@ -388,7 +398,9 @@ copied to `.github/actions/drainpipe` in your project: ```json "extra": { "drainpipe": { - "github": [] + "acquia": { + "github": [] + } } } ``` diff --git a/scaffold/acquia/.drainpipeignore b/scaffold/acquia/.drainpipeignore new file mode 100644 index 000000000..70250dbfb --- /dev/null +++ b/scaffold/acquia/.drainpipeignore @@ -0,0 +1,3 @@ +# Acquia reserved paths +/docroot/sites/default/files +/sites/default/files diff --git a/scaffold/acquia/settings.acquia.php b/scaffold/acquia/settings.acquia.php new file mode 100644 index 000000000..6c19e2100 --- /dev/null +++ b/scaffold/acquia/settings.acquia.php @@ -0,0 +1,70 @@ +> $GITHUB_ENV + echo "Created GitHub Deployment ID $GITHUB_DEPLOYMENT_ID" + if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi + curl -f -H "Authorization: token ${{ inputs.github-token }}" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d '{"state":"in_progress"}' + shell: bash diff --git a/scaffold/github/actions/common/deployment-status/action.yml b/scaffold/github/actions/common/deployment-status/action.yml new file mode 100644 index 000000000..db14e5e81 --- /dev/null +++ b/scaffold/github/actions/common/deployment-status/action.yml @@ -0,0 +1,24 @@ +name: 'Sets the GitHub Deployment status' +description: 'Sets a GitHub deployment to success or failure' +inputs: + github-token: + description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" + required: true + environment-url: + description: "The environment URL" + required: true +runs: + using: "composite" + steps: + - uses: ./.github/actions/drainpipe/set-env + + - name: Set deployment to success + run: | + curl -f -H "Authorization: token ${{ inputs.github-token }}" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"success\", \"environment_url\": \"${{ inputs.environment-url }}\"}" + shell: bash + + - name: Set Deployment Failure Status + run: | + curl -f -H "Authorization: token ${{ inputs.github-token }}" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"failure\"}" + if: ${{ failure() }} + shell: bash diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 222b87550..030fae1d8 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -300,6 +300,33 @@ private function installCICommands(): void } } + if (isset($this->extra['drainpipe']['acquia'])) { + if (!empty($this->extra['drainpipe']['acquia']['settings'])) { + // settings.acquia.php + if (!file_exists('./web/sites/default/settings.acquia.php')) { + $fs->copy("$scaffoldPath/acquia/settings.acquia.php", './web/sites/default/settings.acquia.php'); + } + if (file_exists('./web/sites/default/settings.php')) { + $settings = file_get_contents('./web/sites/default/settings.php'); + if (strpos($settings, 'settings.acquia.php') === false) { + $include = <<<'EOT' +include __DIR__ . "/settings.acquia.php"; +EOT; + file_put_contents('./web/sites/default/settings.php', $include . PHP_EOL, FILE_APPEND); + } + } + } + if (isset($this->extra['drainpipe']['acquia']['github'])) { + $fs->removeDirectory('./.github/actions/drainpipe/acquia'); + $fs->ensureDirectoryExists('./.github/actions/drainpipe/acquia'); + $fs->ensureDirectoryExists('./.github/workflows'); + $fs->copy("$scaffoldPath/github/actions/acquia", './.github/actions/drainpipe/acquia'); + if (!file_exists('.drainpipeignore')) { + $fs->copy("$scaffoldPath/acquia/.drainpipeignore", '.drainpipeignore'); + } + } + } + // Tugboat if (isset($this->extra['drainpipe']['tugboat'])) { $fs->removeDirectory('./.tugboat'); diff --git a/tasks/acquia.yml b/tasks/acquia.yml index 50df8c1ce..29a538d84 100644 --- a/tasks/acquia.yml +++ b/tasks/acquia.yml @@ -1,6 +1,12 @@ version: '3' tasks: + auth: + cmds: + - if [ -z "$ACQUIA_API_KEY" ]; then echo "ACQUIA_API_KEY is empty, please add it to your .env file"; exit 1; fi + - if [ -z "$ACQUIA_API_SECRET" ]; then echo "ACQUIA_API_SECRET is empty, please add it to your .env file"; exit 1; fi + - echo "💧 Authorising with Acquia" + - acli auth:login --no-interaction --key=${ACQUIA_API_KEY} --secret=${ACQUIA_API_SECRET} fetch-db: desc: "Fetches a database from Acquia" env: @@ -9,10 +15,7 @@ tasks: cmds: - mkdir -p $DB_DIR - rm -f $DB_DIR/db.sql.gz $DB_DIR/db.sql - - if [ -z "$ACQUIA_API_KEY" ]; then echo "ACQUIA_API_KEY is empty, please add it to your .env file"; exit 1; fi - - if [ -z "$ACQUIA_API_SECRET" ]; then echo "ACQUIA_API_SECRET is empty, please add it to your .env file"; exit 1; fi - - echo "💧 Authorising with Acquia" - - acli auth:login --no-interaction --key=${ACQUIA_API_KEY} --secret=${ACQUIA_API_SECRET} + - task: auth - echo "💧 Fetching database from Acquia" - acli pull:database {{.ACQUIA_ENVIRONMENT_ID}} $DB_NAME --no-import --no-interaction - | From 652d845b9246ade2f897c6a6497af059ae0571cc Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 5 Mar 2024 16:50:37 +0000 Subject: [PATCH 04/14] Source a different file if we're testing ourselves --- scaffold/github/actions/acquia/clone-env/action.yml | 6 +++++- scaffold/github/actions/acquia/deploy/action.yml | 6 +++++- scaffold/github/actions/acquia/push/action.yml | 6 +++++- scaffold/github/actions/acquia/update/action.yml | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scaffold/github/actions/acquia/clone-env/action.yml b/scaffold/github/actions/acquia/clone-env/action.yml index c905952fc..12637b592 100644 --- a/scaffold/github/actions/acquia/clone-env/action.yml +++ b/scaffold/github/actions/acquia/clone-env/action.yml @@ -18,7 +18,11 @@ runs: steps: - name: Clone Environment run: | - source .github/actions/drainpipe/set-env/bash_aliases + if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then + source .github/actions/drainpipe/set-env/bash_aliases + else + source ../../common/set-env/bash_aliases + fi drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" drainpipe_exec "acli env:mirror --no-config --no-interaction ${{ inputs.source-environment }} ${{ inputs.target-environment }}" shell: bash diff --git a/scaffold/github/actions/acquia/deploy/action.yml b/scaffold/github/actions/acquia/deploy/action.yml index 0735bffe8..c68937f93 100644 --- a/scaffold/github/actions/acquia/deploy/action.yml +++ b/scaffold/github/actions/acquia/deploy/action.yml @@ -35,7 +35,11 @@ runs: - name: Put side in Maintenance Mode run: | - source .github/actions/drainpipe/set-env/bash_aliases + if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then + source .github/actions/drainpipe/set-env/bash_aliases + else + source ../../common/set-env/bash_aliases + fi drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENVIRONMENT="${{ inputs.environment }}" APPLICATION=${ENVIRONMENT%.*} diff --git a/scaffold/github/actions/acquia/push/action.yml b/scaffold/github/actions/acquia/push/action.yml index 49e034613..2171cd1eb 100644 --- a/scaffold/github/actions/acquia/push/action.yml +++ b/scaffold/github/actions/acquia/push/action.yml @@ -18,7 +18,11 @@ runs: steps: - name: Push to Acquia run: | - source .github/actions/drainpipe/set-env/bash_aliases + if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then + source .github/actions/drainpipe/set-env/bash_aliases + else + source ../../common/set-env/bash_aliases + fi drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENV_INFO=$(drainpipe_exec "acli api:environments:find ${{ inputs.environment }}") VCS_TYPE=$(echo $ENV_INFO | jq -r ".vcs.type") diff --git a/scaffold/github/actions/acquia/update/action.yml b/scaffold/github/actions/acquia/update/action.yml index c3cbc8a3d..36d9a0181 100644 --- a/scaffold/github/actions/acquia/update/action.yml +++ b/scaffold/github/actions/acquia/update/action.yml @@ -12,7 +12,11 @@ runs: steps: - name: Update site on Acquia run: | - source .github/actions/drainpipe/set-env/bash_aliases + if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then + source .github/actions/drainpipe/set-env/bash_aliases + else + source ../../common/set-env/bash_aliases + fi drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENVIRONMENT="${{ inputs.environment }}" APPLICATION=${ENVIRONMENT%.*} From cee500ddad82c7f3924902c8791ae7836f9fa7e4 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 5 Mar 2024 17:15:04 +0000 Subject: [PATCH 05/14] Move actions to .github/actions --- .../drainpipe}/acquia/clone-env/action.yml | 6 +----- .../actions/drainpipe}/acquia/deploy/action.yml | 16 +++++----------- .../actions/drainpipe}/acquia/push/action.yml | 6 +----- .../actions/drainpipe}/acquia/update/action.yml | 6 +----- .../common/deployment-create/action.yml | 0 .../common/deployment-status/action.yml | 0 .../actions/drainpipe/common/set-env/action.yml | 17 +++++++++++++++++ .../drainpipe/common/set-env/bash_aliases | 7 +++++++ composer.json | 2 +- src/ScaffoldInstallerPlugin.php | 6 +++++- tests/local-test.sh | 1 + 11 files changed, 39 insertions(+), 28 deletions(-) rename {scaffold/github/actions => .github/actions/drainpipe}/acquia/clone-env/action.yml (79%) rename {scaffold/github/actions => .github/actions/drainpipe}/acquia/deploy/action.yml (84%) rename {scaffold/github/actions => .github/actions/drainpipe}/acquia/push/action.yml (86%) rename {scaffold/github/actions => .github/actions/drainpipe}/acquia/update/action.yml (85%) rename {scaffold/github/actions => .github/actions/drainpipe}/common/deployment-create/action.yml (100%) rename {scaffold/github/actions => .github/actions/drainpipe}/common/deployment-status/action.yml (100%) create mode 100644 .github/actions/drainpipe/common/set-env/action.yml create mode 100644 .github/actions/drainpipe/common/set-env/bash_aliases diff --git a/scaffold/github/actions/acquia/clone-env/action.yml b/.github/actions/drainpipe/acquia/clone-env/action.yml similarity index 79% rename from scaffold/github/actions/acquia/clone-env/action.yml rename to .github/actions/drainpipe/acquia/clone-env/action.yml index 12637b592..2c0072f89 100644 --- a/scaffold/github/actions/acquia/clone-env/action.yml +++ b/.github/actions/drainpipe/acquia/clone-env/action.yml @@ -18,11 +18,7 @@ runs: steps: - name: Clone Environment run: | - if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then - source .github/actions/drainpipe/set-env/bash_aliases - else - source ../../common/set-env/bash_aliases - fi + source .github/actions/drainpipe/common/set-env/bash_aliases drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" drainpipe_exec "acli env:mirror --no-config --no-interaction ${{ inputs.source-environment }} ${{ inputs.target-environment }}" shell: bash diff --git a/scaffold/github/actions/acquia/deploy/action.yml b/.github/actions/drainpipe/acquia/deploy/action.yml similarity index 84% rename from scaffold/github/actions/acquia/deploy/action.yml rename to .github/actions/drainpipe/acquia/deploy/action.yml index c68937f93..63ec615b6 100644 --- a/scaffold/github/actions/acquia/deploy/action.yml +++ b/.github/actions/drainpipe/acquia/deploy/action.yml @@ -25,21 +25,15 @@ inputs: runs: using: "composite" steps: - - uses: ./.github/actions/drainpipe/set-env - - name: Create GitHub Deployment - uses: ../../common/deployment-create + uses: .github/actions/drainpipe/common/deployment-create with: github-token: ${{ inputs.github-token }} environment: ${{ inputs.environment }} - name: Put side in Maintenance Mode run: | - if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then - source .github/actions/drainpipe/set-env/bash_aliases - else - source ../../common/set-env/bash_aliases - fi + source .github/actions/drainpipe/common/set-env/bash_aliases drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENVIRONMENT="${{ inputs.environment }}" APPLICATION=${ENVIRONMENT%.*} @@ -48,7 +42,7 @@ runs: shell: bash - name: Push to Acquia - uses: ../push + uses: .github/actions/drainpipe/acquia/push with: environment: ${{ inputs.environment }} commit-message: ${{ inputs.commit-message }} @@ -56,13 +50,13 @@ runs: api-secret: ${{ inputs.api-secret }} - name: Run updates - uses: ../update + uses: .github/actions/drainpipe/acquia/update with: environment: ${{ inputs.environment }} run-installer: ${{ inputs.run-installer }} - name: Set Deployment Status - uses: ../../common/deployment-status + uses: .github/actions/drainpipe/common/deployment-status with: github-token: ${{ inputs.github-token }} environment-url: ${{ inputs.environment-url }} diff --git a/scaffold/github/actions/acquia/push/action.yml b/.github/actions/drainpipe/acquia/push/action.yml similarity index 86% rename from scaffold/github/actions/acquia/push/action.yml rename to .github/actions/drainpipe/acquia/push/action.yml index 2171cd1eb..f165401e4 100644 --- a/scaffold/github/actions/acquia/push/action.yml +++ b/.github/actions/drainpipe/acquia/push/action.yml @@ -18,11 +18,7 @@ runs: steps: - name: Push to Acquia run: | - if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then - source .github/actions/drainpipe/set-env/bash_aliases - else - source ../../common/set-env/bash_aliases - fi + source .github/actions/drainpipe/common/set-env/bash_aliases drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENV_INFO=$(drainpipe_exec "acli api:environments:find ${{ inputs.environment }}") VCS_TYPE=$(echo $ENV_INFO | jq -r ".vcs.type") diff --git a/scaffold/github/actions/acquia/update/action.yml b/.github/actions/drainpipe/acquia/update/action.yml similarity index 85% rename from scaffold/github/actions/acquia/update/action.yml rename to .github/actions/drainpipe/acquia/update/action.yml index 36d9a0181..512ba70ad 100644 --- a/scaffold/github/actions/acquia/update/action.yml +++ b/.github/actions/drainpipe/acquia/update/action.yml @@ -12,11 +12,7 @@ runs: steps: - name: Update site on Acquia run: | - if [[ -f ".github/actions/drainpipe/set-env/bash_aliases" ]]; then - source .github/actions/drainpipe/set-env/bash_aliases - else - source ../../common/set-env/bash_aliases - fi + source .github/actions/drainpipe/common/set-env/bash_aliases drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth" ENVIRONMENT="${{ inputs.environment }}" APPLICATION=${ENVIRONMENT%.*} diff --git a/scaffold/github/actions/common/deployment-create/action.yml b/.github/actions/drainpipe/common/deployment-create/action.yml similarity index 100% rename from scaffold/github/actions/common/deployment-create/action.yml rename to .github/actions/drainpipe/common/deployment-create/action.yml diff --git a/scaffold/github/actions/common/deployment-status/action.yml b/.github/actions/drainpipe/common/deployment-status/action.yml similarity index 100% rename from scaffold/github/actions/common/deployment-status/action.yml rename to .github/actions/drainpipe/common/deployment-status/action.yml diff --git a/.github/actions/drainpipe/common/set-env/action.yml b/.github/actions/drainpipe/common/set-env/action.yml new file mode 100644 index 000000000..32862b6fe --- /dev/null +++ b/.github/actions/drainpipe/common/set-env/action.yml @@ -0,0 +1,17 @@ +name: 'Set Env' +description: 'Creates some useful environment variables' +inputs: + github-api-token: + description: "GitHub API token" + required: true + github-api-token-username: + description: "GitHub API token username" + required: true +runs: + using: "composite" + steps: + - run: | + echo "Setting Drainpipe environment variables:" + echo "DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV + echo "DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)" >> $GITHUB_ENV + shell: bash diff --git a/.github/actions/drainpipe/common/set-env/bash_aliases b/.github/actions/drainpipe/common/set-env/bash_aliases new file mode 100644 index 000000000..58fca27a8 --- /dev/null +++ b/.github/actions/drainpipe/common/set-env/bash_aliases @@ -0,0 +1,7 @@ +drainpipe_exec() { + if [ "$DRAINPIPE_DDEV" == "true" ]; then + ddev exec "$@" + else + eval "$@" + fi +} diff --git a/composer.json b/composer.json index 4d79401c8..dba6bebbc 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,6 @@ } }, "archive": { - "exclude": ["/.github", "/.yarn", "/drainpipe-dev", "/metapackages"] + "exclude": ["/.github/workflows", "/.yarn", "/drainpipe-dev", "/metapackages"] } } diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 030fae1d8..7ed70471f 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -220,6 +220,7 @@ private function installDdevCommand(): void private function installCICommands(): void { $scaffoldPath = $this->config->get('vendor-dir') . '/lullabot/drainpipe/scaffold'; + $actionsPath = $this->config->get('vendor-dir') . '/lullabot/drainpipe/.github/actions'; $fs = new Filesystem(); // GitLab $fs->removeDirectory('./.drainpipe/gitlab'); @@ -318,9 +319,12 @@ private function installCICommands(): void } if (isset($this->extra['drainpipe']['acquia']['github'])) { $fs->removeDirectory('./.github/actions/drainpipe/acquia'); + $fs->removeDirectory('./.github/actions/drainpipe/common'); $fs->ensureDirectoryExists('./.github/actions/drainpipe/acquia'); + $fs->ensureDirectoryExists('./.github/actions/drainpipe/common'); $fs->ensureDirectoryExists('./.github/workflows'); - $fs->copy("$scaffoldPath/github/actions/acquia", './.github/actions/drainpipe/acquia'); + $fs->copy("$actionsPath/acquia", './.github/actions/drainpipe/acquia'); + $fs->copy("$actionsPath/common", './.github/actions/drainpipe/common'); if (!file_exists('.drainpipeignore')) { $fs->copy("$scaffoldPath/acquia/.drainpipeignore", '.drainpipeignore'); } diff --git a/tests/local-test.sh b/tests/local-test.sh index 2be72c535..6271e3cba 100755 --- a/tests/local-test.sh +++ b/tests/local-test.sh @@ -17,6 +17,7 @@ ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true ddev composer config --no-plugins allow-plugins.lullabot/drainpipe-dev true ddev composer config repositories.drainpipe --json '{"type": "path", "url": "drainpipe", "options": {"symlink": false}}' ddev composer config repositories.drainpipe-dev --json '{"type": "path", "url": "drainpipe/drainpipe-dev", "options": {"symlink": false}}' +ddev composer config extra.drainpipe.acquia --json '{"settings": true, "github": []}' ddev composer config minimum-stability dev ddev composer require "lullabot/drainpipe @dev" --with-all-dependencies ddev composer require "lullabot/drainpipe-dev @dev" --dev --with-all-dependencies From aef7660f4ac308efb91b51f5f1ca9d7cc4a50e70 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 5 Mar 2024 17:19:29 +0000 Subject: [PATCH 06/14] Change back paths --- src/ScaffoldInstallerPlugin.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ScaffoldInstallerPlugin.php b/src/ScaffoldInstallerPlugin.php index 7ed70471f..ed69c0ce9 100644 --- a/src/ScaffoldInstallerPlugin.php +++ b/src/ScaffoldInstallerPlugin.php @@ -318,13 +318,11 @@ private function installCICommands(): void } } if (isset($this->extra['drainpipe']['acquia']['github'])) { - $fs->removeDirectory('./.github/actions/drainpipe/acquia'); - $fs->removeDirectory('./.github/actions/drainpipe/common'); + $fs->removeDirectory('./.github/actions/drainpipe'); $fs->ensureDirectoryExists('./.github/actions/drainpipe/acquia'); - $fs->ensureDirectoryExists('./.github/actions/drainpipe/common'); $fs->ensureDirectoryExists('./.github/workflows'); $fs->copy("$actionsPath/acquia", './.github/actions/drainpipe/acquia'); - $fs->copy("$actionsPath/common", './.github/actions/drainpipe/common'); + $fs->copy("$actionsPath/common", './.github/actions/drainpipe'); if (!file_exists('.drainpipeignore')) { $fs->copy("$scaffoldPath/acquia/.drainpipeignore", '.drainpipeignore'); } From abc86f6786d14757dc658ac32def0781dd76b830 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 12 Mar 2024 12:21:31 +0000 Subject: [PATCH 07/14] Update .github/actions/drainpipe/acquia/deploy/action.yml Co-authored-by: Beto Aveiga --- .github/actions/drainpipe/acquia/deploy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/drainpipe/acquia/deploy/action.yml b/.github/actions/drainpipe/acquia/deploy/action.yml index 63ec615b6..1392fbf6c 100644 --- a/.github/actions/drainpipe/acquia/deploy/action.yml +++ b/.github/actions/drainpipe/acquia/deploy/action.yml @@ -1,5 +1,5 @@ name: 'Deploy a branch to Acquia' -description: 'Deploys a review app to Pantheon Multidev' +description: 'Deploys a review app to an Acquia Environment' inputs: github-token: description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" From b631e9dfb171b9ad1df671d5d5287751c69833bf Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 12 Mar 2024 12:33:20 +0000 Subject: [PATCH 08/14] Update .github/workflows/TestAcquia.yml Co-authored-by: Beto Aveiga --- .github/workflows/TestAcquia.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TestAcquia.yml b/.github/workflows/TestAcquia.yml index b0c5a6ef1..27b08f4bb 100644 --- a/.github/workflows/TestAcquia.yml +++ b/.github/workflows/TestAcquia.yml @@ -7,7 +7,7 @@ on: concurrency: development jobs: - Test-Pantheon: + Test-Acquia: runs-on: ubuntu-22.04 steps: - name: Create a Drupal project From 8ca5fa16607ab94ba03a4fe52daf506af16ab95c Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 12 Mar 2024 12:33:27 +0000 Subject: [PATCH 09/14] Update README.md Co-authored-by: Beto Aveiga --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e33b0581e..a56f34200 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ includes: See below for CI specific integrations for hosting providers. ### Acquia -Acquia specific tasks are contained in [`tasks/pantheon.yml`](tasks/pantheon.yml). +Acquia specific tasks are contained in [`tasks/acquia.yml`](tasks/acquia.yml). Add the following to your `Taskfile.yml`'s `includes` section to use them: ```yml includes: From c580937fbdc8ab2e88919f41a1e9c1968413921d Mon Sep 17 00:00:00 2001 From: Sally Young Date: Tue, 12 Mar 2024 12:33:39 +0000 Subject: [PATCH 10/14] Update README.md Co-authored-by: Beto Aveiga --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a56f34200..7778a733d 100644 --- a/README.md +++ b/README.md @@ -378,7 +378,7 @@ includes: ``` | | | |------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `task acquia:fetch-db` | Fetches a database from Pantheon. Set `ACQUIA_ENVIRONMENT_ID` in Taskfile `vars`, along with `ACQUIA_API_KEY` and `ACQUIA_API_SECRET` as environment variables | +| `task acquia:fetch-db` | Fetches a database from Acquia. Set `ACQUIA_ENVIRONMENT_ID` in Taskfile `vars`, along with `ACQUIA_API_KEY` and `ACQUIA_API_SECRET` as environment variables | To enable auto configuration of Acquia Cloud settings: ```json From b15f123494d28d7a0ea8ccdca29c87474a9ab796 Mon Sep 17 00:00:00 2001 From: Luis Aveiga Date: Tue, 5 Nov 2024 14:33:17 -0500 Subject: [PATCH 11/14] To trigger CI workflows From 6f3298b07129d519749f5627493f03832a74d712 Mon Sep 17 00:00:00 2001 From: Luis Aveiga Date: Tue, 5 Nov 2024 16:42:48 -0500 Subject: [PATCH 12/14] To trigger workflows --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7778a733d..a900d6b7b 100644 --- a/README.md +++ b/README.md @@ -625,3 +625,4 @@ tugboat:php:init: - apt-get install -y libldap2-dev - docker-php-ext-install ldap ``` + From c67f6bc4284be0edc5b1a630e715510da009c301 Mon Sep 17 00:00:00 2001 From: Luis Aveiga Date: Tue, 5 Nov 2024 17:26:19 -0500 Subject: [PATCH 13/14] ISSUE-204: restoring README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a900d6b7b..7778a733d 100644 --- a/README.md +++ b/README.md @@ -625,4 +625,3 @@ tugboat:php:init: - apt-get install -y libldap2-dev - docker-php-ext-install ldap ``` - From e629fd294b72dad696728e7f1ab47dd8c1bcdac5 Mon Sep 17 00:00:00 2001 From: Sally Young Date: Mon, 3 Feb 2025 14:03:54 +0000 Subject: [PATCH 14/14] Update .github/actions/drainpipe/acquia/deploy/action.yml Co-authored-by: Andrew Berry --- .github/actions/drainpipe/acquia/deploy/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/drainpipe/acquia/deploy/action.yml b/.github/actions/drainpipe/acquia/deploy/action.yml index 1392fbf6c..0a98b91b9 100644 --- a/.github/actions/drainpipe/acquia/deploy/action.yml +++ b/.github/actions/drainpipe/acquia/deploy/action.yml @@ -31,7 +31,7 @@ runs: github-token: ${{ inputs.github-token }} environment: ${{ inputs.environment }} - - name: Put side in Maintenance Mode + - name: Put site in Maintenance Mode run: | source .github/actions/drainpipe/common/set-env/bash_aliases drainpipe_exec "ACQUIA_API_KEY=${{ inputs.api-key }} ACQUIA_API_SECRET=${{ inputs.api-secret }} ./vendor/bin/task acquia:auth"