-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #204: Add a task for interacting with Acquia #442
base: main
Are you sure you want to change the base?
Changes from 10 commits
1ce6e34
6118b7a
a67e79f
652d845
cee500d
aef7660
abc86f6
b631e9d
8ca5fa1
c580937
b15f123
6f3298b
c67f6bc
4d60f15
d5d12a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "Clone Environment" | ||
description: "Clones an Acquia Environment to another site" | ||
inputs: | ||
source-environment: | ||
description: "Source environment i.e. the uuid or environment alias" | ||
required: true | ||
target-environment: | ||
description: "Target environment i.e. the uuid or environment alias" | ||
required: true | ||
api-key: | ||
description: "Acquia API Key" | ||
required: true | ||
api-secret: | ||
description: "Acquia API Secret" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Clone Environment | ||
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" | ||
drainpipe_exec "acli env:mirror --no-config --no-interaction ${{ inputs.source-environment }} ${{ inputs.target-environment }}" | ||
shell: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: 'Deploy a branch to Acquia' | ||
description: 'Deploys a review app to an Acquia Environment' | ||
inputs: | ||
github-token: | ||
description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" | ||
required: true | ||
environment: | ||
description: "The environment to push to, either uuid or alias" | ||
required: true | ||
environment-url: | ||
description: "The environment URL" | ||
required: true | ||
run-installer: | ||
description: "Whether or not to run the Drupal site installer. Defaults to false." | ||
required: false | ||
commit-message: | ||
description: "The commit message to use when pushing to Acquia" | ||
required: true | ||
api-key: | ||
description: "Acquia API Key" | ||
required: true | ||
api-secret: | ||
description: "Acquia API Secret" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Create GitHub Deployment | ||
uses: .github/actions/drainpipe/common/deployment-create | ||
with: | ||
github-token: ${{ inputs.github-token }} | ||
environment: ${{ inputs.environment }} | ||
|
||
- name: Put side 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" | ||
ENVIRONMENT="${{ inputs.environment }}" | ||
APPLICATION=${ENVIRONMENT%.*} | ||
drainpipe_exec "acli remote:aliases:download --no-interaction $APPLICATION" | ||
drainpipe_exec "./vendor/bin/task drupal:maintenance:on [email protected]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
shell: bash | ||
|
||
- name: Push to Acquia | ||
uses: .github/actions/drainpipe/acquia/push | ||
with: | ||
environment: ${{ inputs.environment }} | ||
commit-message: ${{ inputs.commit-message }} | ||
api-key: ${{ inputs.api-key }} | ||
api-secret: ${{ inputs.api-secret }} | ||
|
||
- name: Run updates | ||
uses: .github/actions/drainpipe/acquia/update | ||
with: | ||
environment: ${{ inputs.environment }} | ||
run-installer: ${{ inputs.run-installer }} | ||
|
||
- name: Set Deployment Status | ||
uses: .github/actions/drainpipe/common/deployment-status | ||
with: | ||
github-token: ${{ inputs.github-token }} | ||
environment-url: ${{ inputs.environment-url }} | ||
|
||
- name: Take site out of Maintenance Mode | ||
run: | | ||
drainpipe_exec "./vendor/bin/task drupal:maintenance:on site=@${{ inputs.environment }}" | ||
shell: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: 'Push code to Acquia' | ||
description: 'Pushes code to an Acquia environment' | ||
inputs: | ||
environment: | ||
description: "The environment to push to, either uuid or alias" | ||
required: true | ||
commit-message: | ||
description: "The commit message to use when pushing to Acquia" | ||
required: true | ||
api-key: | ||
description: "Acquia API Key" | ||
required: true | ||
api-secret: | ||
description: "Acquia API Secret" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Push to Acquia | ||
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" | ||
ENV_INFO=$(drainpipe_exec "acli api:environments:find ${{ inputs.environment }}") | ||
VCS_TYPE=$(echo $ENV_INFO | jq -r ".vcs.type") | ||
if [ "$VCS_TYPE" != "git" ]; then | ||
echo "Unrecognised VCS type" | ||
exit 1 | ||
fi | ||
BRANCH=$(echo $ENV_INFO | jq -r ".vcs.path") | ||
REMOTE=$(echo $ENV_INFO | jq -r ".vcs.url") | ||
drainpipe_exec "./vendor/bin/task deploy:git directory=/tmp/release branch=\"$BRANCH\" remote=\"$REMOTE\" message=\"${{ inputs.commit-message }}\"" | ||
# Run code-switch to the same branch so we wait for everything to sync. | ||
drainpipe_exec "acli api:environments:code-switch ${{ inputs.environment }} \"$BRANCH\"" | ||
shell: bash | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: "Update or Install Acquia Site" | ||
description: "Runs the Drupal updater or the site installer in an Acquia environment" | ||
inputs: | ||
environment: | ||
description: "The environment to run the updates or install in, either uuid or alias e.g. 'test'" | ||
required: true | ||
run-installer: | ||
description: "Whether or not to run the Drupal site installer. Defaults to false." | ||
required: false | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Update site on Acquia | ||
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" | ||
ENVIRONMENT="${{ inputs.environment }}" | ||
APPLICATION=${ENVIRONMENT%.*} | ||
drainpipe_exec "acli remote:aliases:download --no-interaction $APPLICATION" | ||
if [ "${{ inputs.run-installer }}" == "true" ]; then | ||
drainpipe_exec "./vendor/bin/drush @${{ inputs.environment }} --yes site:install --existing-config" | ||
elif drainpipe_exec "./vendor/bin/task -l | grep '* update: ')"; then | ||
drainpipe_exec "./vendor/bin/task update site=@${{ inputs.environment }}" | ||
else | ||
drainpipe_exec "./vendor/bin/task drupal:update site=@${{ inputs.environment }}" | ||
fi | ||
shell: bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: 'Create a GitHub deployment' | ||
description: 'Creates a GitHub deployment and echos the ID to the $GITHUB_ENV file' | ||
inputs: | ||
github-token: | ||
description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" | ||
required: true | ||
environment: | ||
description: "The environment name" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: ./.github/actions/drainpipe/set-env | ||
|
||
- name: Create GitHub Deployment | ||
run: | | ||
export GITHUB_DEPLOYMENT=$(curl -f -X POST \ | ||
https://api.github.com/repos/$GITHUB_REPOSITORY/deployments \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
-H "Authorization: token ${{ inputs.github-token }}" \ | ||
-d "{\"ref\": \"$DRAINPIPE_SHA\", \"auto_merge\": false, \"environment\": \"${{ inputs.environment }}\", \"transient_environment\": false, \"required_contexts\": [], \"description\": \"Acquia Cloud environment\"}" \ | ||
) | ||
export GITHUB_DEPLOYMENT_ID=$(echo $GITHUB_DEPLOYMENT | jq '.id') | ||
echo "GITHUB_DEPLOYMENT_ID=$GITHUB_DEPLOYMENT_ID" >> $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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
drainpipe_exec() { | ||
if [ "$DRAINPIPE_DDEV" == "true" ]; then | ||
ddev exec "$@" | ||
else | ||
eval "$@" | ||
fi | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: "Test Acquia" | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
concurrency: development | ||
|
||
jobs: | ||
Test-Acquia: | ||
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: [email protected] | ||
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 | ||
|
||
Comment on lines
+31
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beto-aveiga it's a ddev bug, will be fixed in the next release. We fixed it on main for #729 and you can do something similar here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beto-aveiga during the Drainpipe sync today it was mentioned that our workaround for DDEV is no longer needed because it's been addressed in the latest release (v1.24.0). We can remove any workaround that we added (even though it would work fine if we left it in). |
||
- 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 '<?php' > 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 }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Acquia reserved paths | ||
/docroot/sites/default/files | ||
/sites/default/files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.