/drupal_extension_scaffold_destination_github

Destination demo repository for https://github.com/drevops/drupal_extension_scaffold deployed from GitHub Actions. 🛠 The default branch is set to `1.x`.

Primary LanguageShellGNU General Public License v3.0GPL-3.0

Drupal extension scaffold

Drupal extension scaffold

GitHub Issues GitHub Pull Requests Build, test and deploy CircleCI codecov GitHub release (latest by date) LICENSE Renovate

Drupal 10 Drupal 11


Drupal extension template for development and testing in CI of your choice with mirroring to Drupal.org

Use case

Perform extension development in GitHub with testing in CI, and push code committed only to the main branches (1.x, 2.x etc.) to drupal.org.

Features

  • Turnkey CI configuration with artifacts and test results support.
  • Tools:
    • Develop locally using PHP running on your host using identical .devtools scripts as in CI.
      • Uses drupal-composer/drupal-project to create drupal site structure. Providing a custom fork of drupal-project is also supported.
      • Additional development dependenices provided in composer.dev.json. These are merged during the codebase build.
      • The extension can installed as a module or a theme: modify type property set in the info.yml file.
      • Additional dependencies can be added for integration testing between extensions: add dependency into suggest section of composer.json. Build process
      • Patches can be applied to the dependencies: add a patch to the patches section of composer.json. Local patches will be sourced from the patches directory.
    • Codings standards checking:
      • PHP code standards checking against Drupal and DrupalPractice standards.
      • PHP code static analysis with PHPStan (including PHPStan Drupal).
      • PHP deprecated code analysis with Drupal Rector.
      • Twig code analysis with Twig CS Fixer. Lint process
    • PHPUnit testing support Test process
    • Renovate configuration to keep your repository dependencies up-to-date.
  • Deployment:
    • Mirroring of the repo to drupal.org (or any other git repo) on release.
    • Deploy to a destination branch different from the source branch.
    • Tags mirroring.
  • This template is tested in the same way as a project using it.
GitHub Actions CircleCI
Screenshot of CI jobs in GitHub Actions Screenshot of CI jobs in CircleCi

Setup

  1. Create your extension's repository on GitHub.
  2. Download this extension's code by pressing 'Clone or download' button in GitHub UI.
  3. Copy the contents of the downloaded archive into your extension's repository.
  4. Run the initial setup script: ./init.sh. Init process
  5. Commit and push to your new GitHub repo.
  6. Login to your CI and add your new GitHub repository. Your project build will start momentarily.
  7. Configure deployment to drupal.org (see below).
Configure deployment (click to expand)

The CI supports mirroring of main branches (1.x, 10.x-1.x etc.) to drupal.org mirror of the project (to keep both repos in sync).

The deployment job runs when commits are pushed to main branches (1.x, 2.x, 10.x-1.x etc.) or when release tags are created.

Example of deployment repository:

  1. Generate a new SSH key without pass phrase:
ssh-keygen -m PEM -t rsa -b 4096 -C "your_email@example.com"
  1. Add public key to your drupal.org account: https://git.drupalcode.org/-/profile/keys
  2. Add private key to your CI:
  • CircleCI:
    • Go to your project -> Settings -> SSH Permissions
    • Put your private SSH key into the box. Leave Hostname empty.
    • Copy the fingerprint string from the CircleCI User Interface. Then, replace the deploy_ssh_fingerprint value in the .circleci/config.yml file with this copied fingerprint string.
    • Push the code to your repository.
  1. In CI, use UI to add the following variables:
  • DEPLOY_USER_NAME - the name of the user who will be committing to a remote repository (i.e., your name on drupal.org).
  • DEPLOY_USER_EMAIL - the email address of the user who will be committing to a remote repository (i.e., your email on drupal.org).
  • DEPLOY_REMOTE - your extensions remote drupal.org repository ( i.e. git@git.drupal.org:project/myextension.git).
  • DEPLOY_PROCEED - set to 1 once CI is working, and you are ready to deploy.

To debug SSH connection used by Git, add GIT_SSH_COMMAND variable with value ssh -vvv. This will output verbose information about the SSH connection and key used.