Feature request to add a sub module that supports triggering Github Actions workflow dispatch event.
Based off of the Netlify sub module, this will support POST requests that require a Github personal access token.

See: https://docs.github.com/en/rest/reference/actions#create-a-workflow-disp...

Comments

ben.hamelin created an issue. See original summary.

ben.hamelin’s picture

Version: 3.2.0 » 3.x-dev
Status: Active » Needs review
StatusFileSize
new8.84 KB

Patch attached for new sub module.

larowlan’s picture

Thanks, this looks neat.
Can we get a test added and I'm happy to put this out as 3.3.0

See \Drupal\Tests\build_hooks_bitbucket\Kernel\BitbucketBuildHooksTest for an example, there are utility methods that make it pretty straightforward to add a new test.

petar_basic’s picture

StatusFileSize
new0 bytes

Here's a patch with implemented tests.

petar_basic’s picture

StatusFileSize
new13.34 KB

Sorry, the patch in the previous comment was empty.

Status: Needs review » Needs work

The last submitted patch, 5: github-actions-hooks-3227142-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

petar_basic’s picture

StatusFileSize
new13.5 KB

Corrected tests. Sorry for the multiple comments.

petar_basic’s picture

StatusFileSize
new13.01 KB

And here is the patch with corrected code styling/standards.

petar_basic’s picture

Status: Needs work » Needs review
larowlan’s picture

Status: Needs review » Needs work
  1. +++ b/modules/build_hooks_github/src/Plugin/FrontendEnvironment/GithubFrontendEnvironment.php
    @@ -0,0 +1,121 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    +    return new static(
    +      $configuration,
    +      $plugin_id,
    +      $plugin_definition
    +    );
    +  }
    

    do we need this if we're not injecting any services?

    happy to leave it in

  2. +++ b/modules/build_hooks_github/src/Plugin/FrontendEnvironment/GithubFrontendEnvironment.php
    @@ -0,0 +1,121 @@
    +    $config_factory = \Drupal::configFactory();
    

    Ah - we're implementing ContainerFactoryPluginInterface, but we're not using DI

    Can we inject this?

    And the messenger

  3. +++ b/modules/build_hooks_github/src/Plugin/FrontendEnvironment/GithubFrontendEnvironment.php
    @@ -0,0 +1,121 @@
    +    // This plugin adds to the deployment form a fieldset displaying the
    +    // latest deployments:
    +    $form = [];
    +
    ...
    +  public static function refreshDeploymentTable(array $form, FormStateInterface $form_state) {
    +    return $form['latestGithubDeployments']['table'];
    

    this doesn't look implemented, so can be removed.

    No need for the ajax callback (refreshDeploymentTable) and the comment about 'latest deployments' can go too

Tests look great, just some minor cleanup now.

petar_basic’s picture

Status: Needs work » Needs review
StatusFileSize
new13.17 KB

Updated the patch:

- Now injecting the config factory
- Removed the messenger since it was not used anywhere.
- Removed the ajax callback (refreshDeploymentTable) and the comment about 'latest deployments'

  • larowlan committed 124d07c on 3.x authored by petar_basic
    Issue #3227142 by petar_basic, ben.hamelin, larowlan: Add Support for...
larowlan’s picture

Status: Needs review » Fixed

Thanks, cutting 3.3.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.