โ† Back to list

๐Ÿš€ Automating Drupal Deployments to Acquia with GitHub Actions

Managing a Drupal site on Acquia? Automate deployments and Drush commands with GitHub Actions for faster, safer releases.

Salman | Exploring & Coding ยท 2025-04-21 08:44 ยท 10 claps ยท 2.8 min read
#drupal #github #acquia #github-actions #ci-cd-pipeline
Open on Medium โ†—
Wiki topics: โ˜๏ธ ยท DevOps & Cloud ๐Ÿ”“ ยท Open Source ๐ŸฅŠ ยท Combat Sports

๐Ÿš€ Automating Drupal Deployments to Acquia with GitHub Actions

If youโ€™re managing a Drupal site hosted on Acquia Cloud Platform, manual deployments and Drush commands can slow you down and introduce risk.

In this article, Iโ€™ll walk you through setting up a production-grade GitHub Actions workflow that deploys to Acquia automatically when a pull request to main is closed (and merged), or when manually triggered.

โœ… Why Use GitHub Actions for Acquia?

  • Fully automated deployments to Acquia Cloud environments (dev, test, prod)
  • Composer install, Drush commands, and config import in one pipeline
  • Safe SSH setup and Acquia CLI usage
  • Clear separation of environments with optional manual dispatch
  • Bonus: Get notifications in Google Chat or Slack after deployment (optional)

๐Ÿ”ง Prerequisites

To make this work, youโ€™ll need:

  1. An Acquia Cloud Site (with SSH access enabled)
  2. A GitHub repository that holds your Drupal project
  3. Public part of your SSH key must be added to Acquia via Cloud > Git > SSH Keys
  4. Repository variables named ACQUIA_SITE (e.g. drupalsite) and ACQUIA_GIT_HOST (e.g svn.prod.hosting.acquia.com)
  5. The following GitHub Secrets added to your repo:
  • ACQUIA_API_KEY_ID โ€“ Your Acquia API Key ID
  • ACQUIA_API_KEY_SECRET โ€“ Your Acquia API Key Secret
  • ACQUIA_SSH_PRIVATE_KEY โ€“ Private SSH key that has access to your Acquia Cloud Git repo
  • Public part of your SSH key must be added to Acquia via Cloud > Git > SSH Keys

๐Ÿ› ๏ธ The GitHub Actions Workflow

Hereโ€™s the full YAML workflow, saved as .github/workflows/deploy.yml:

name: Deploy to Acquia
on:
  pull_request:
    branches: [main]
    types: [closed]
  workflow_dispatch:
    inputs:
      environment:
        description: "Environment"
        required: true
        type: choice
        options: [dev, test, prod]
        default: test
env:
  ACQUIA_SITE: ${{ vars.ACQUIA_SITE }}
  ACQUIA_GIT_HOST: ${{ vars.ACQUIA_GIT_HOST }}
  ACQUIA_CLI_NO_INTERACTION: 1
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment || 'test' }}
    steps:
      - name: Skip if not merged PR or manual trigger
        if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
        run: exit 0
      - name: Set ENV vars
        run: |
          echo "ENVIRONMENT=${{ inputs.environment || 'test' }}" >> $GITHUB_ENV
          echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
      - name: Block non-main to prod
        if: env.ENVIRONMENT == 'prod' && env.BRANCH_NAME != 'main'
        run: exit 1
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          tools: composer
          extensions: mbstring, pdo, xml, gd, curl, zip, bcmath, intl
      - name: Install Composer Dependencies
        run: composer install --no-dev --optimize-autoloader
      - name: Install Acquia CLI
        run: |
          curl -sSL https://github.com/acquia/cli/releases/latest/download/acli.phar -o acli
          chmod +x acli && sudo mv acli /usr/local/bin/acli
      - name: Setup SSH key for Acquia Git
        uses: webfactory/ssh-agent@v0.9.0
        with:
          ssh-private-key: ${{ secrets.ACQUIA_SSH_PRIVATE_KEY }}
      - name: Add Acquia host to known_hosts
        run: ssh-keyscan -H ${{ env.ACQUIA_GIT_HOST }} >> ~/.ssh/known_hosts
      - name: Set Git author info for Acquia commit
        run: |
          git config --global user.name "GitHub Actions"
          git config --global user.email "githubactions@salmanhaider.com"
      - name: Authenticate & Deploy to Acquia
        run: |
          acli auth:login --key=${{ secrets.ACQUIA_API_KEY_ID }} --secret=${{ secrets.ACQUIA_API_KEY_SECRET }}
          acli push:artifact $ACQUIA_SITE.$ENVIRONMENT --no-interaction

          acli remote:drush $ACQUIA_SITE.$ENVIRONMENT -- deploy -y || true

๐ŸŽฏ GitHub Actions UI allowing manual execution by branch and target environment.

๐ŸŽฏ GitHub Actions UI allowing manual execution by branch and target environment.

โœ… Successful deployment log showing artifact push and post-deploy Drush commands on Acquia.

โœ… Successful deployment log showing artifact push and post-deploy Drush commands on Acquia.

๐Ÿ’ก Benefits of This Setup

  • Clean & readable GitHub workflow
  • Handles Composer install + config import
  • Git commit author set (avoids identity errors)
  • SSH securely handled using webfactory/ssh-agent
  • Production protection โ€” prevents accidental deploys from non-main branches
  • Can easily be extended for tag-based deploys, Slack/Chat notifications, or previews

๐Ÿ™Œ Final Thoughts

If youโ€™re deploying to Acquia Cloud and want reproducible, safe, and automated deploys โ€” this GitHub Actions workflow will save your team a ton of time. It enforces best practices, reduces human error, and gets you closer to CI/CD bliss ๐Ÿš€

Got ideas to enhance or optimize this workflow? Letโ€™s collaborate โ€” comment below or connect directly!


๋ฉ”ํƒ€๋ฐ์ดํ„ฐ
post_id
7567a9f8341d
slug
automating-drupal-deployments-to-acquia-with-github-actions-7567a9f8341d
url
https://medium.com/@isalmanhaider/automating-drupal-deployments-to-acquia-with-github-actions-7567a9f8341d
canonical_url
https://medium.com/@isalmanhaider/automating-drupal-deployments-to-acquia-with-github-actions-7567a9f8341d
author_url
https://medium.com/@isalmanhaider
status
ok
fetched_at
2026-07-20 06:08:36