-
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
Open
justafish
wants to merge
14
commits into
main
Choose a base branch
from
justafish/issue-204-acquia-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1ce6e34
Issue #204: Add a task for fetching a database from Acquia
justafish 6118b7a
Allow the db name to be customised
justafish a67e79f
Add GitHub Actions for Acquia
justafish 652d845
Source a different file if we're testing ourselves
justafish cee500d
Move actions to .github/actions
justafish aef7660
Change back paths
justafish abc86f6
Update .github/actions/drainpipe/acquia/deploy/action.yml
justafish b631e9d
Update .github/workflows/TestAcquia.yml
justafish 8ca5fa1
Update README.md
justafish c580937
Update README.md
justafish b15f123
To trigger CI workflows
beto-aveiga 6f3298b
To trigger workflows
beto-aveiga c67f6bc
ISSUE-204: restoring README.md
beto-aveiga 4d60f15
Merge branch 'main' into justafish/issue-204-acquia-integration
justafish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 site=@lullabot8.dev" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
28 changes: 28 additions & 0 deletions
28
.github/actions/drainpipe/common/deployment-create/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
24 changes: 24 additions & 0 deletions
24
.github/actions/drainpipe/common/deployment-status/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 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 '<?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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Acquia reserved paths | ||
/docroot/sites/default/files | ||
/sites/default/files |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Using
composer
with--json
is failing.I'm not clear why.
I also tried multiple JSON configurations through
composer
without success.I used this instead:
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.
@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.