Skip to content
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

Ability to split out PRs? #11

Open
kevinquillen opened this issue Dec 4, 2023 · 3 comments
Open

Ability to split out PRs? #11

kevinquillen opened this issue Dec 4, 2023 · 3 comments

Comments

@kevinquillen
Copy link

I want to run checks for Drupal core updates every few hours. For contrib I want it to run daily. I would like to create PRs for core only, and contrib only. If possible I would like a PR per contrib module, but am fine with contrib grouped for now.

Is this possible? how?

Also, it would be nice if the PR for core updates could automerge (triggering a deployment in my case). Can that be done here?

@valicm
Copy link
Owner

valicm commented Dec 13, 2023

Hi,

You can run multiple GitHub actions and adjust parameters to include/exclude core, but not contrib modules.
I can add an option to run only for the core.

You can split major and minor updates into two actions.

      - name: Check updates
        id: updates
        uses: valicm/drupal-update@v4
        with:
           update_type: semver-safe-update or all (default is semver-safe-update)
           update_core: true or false (default true)
           update_exclude: pathauto,token (default is empty)

See the full definition here: https://github.com/valicm/drupal-update/blob/main/action.yml

The auto merge can be done with this - https://github.com/peter-evans/enable-pull-request-automerge

I don't suggest auto merge for anything except Drupal Core minor.
Except code changes, it's recommended to do the following, because there could be some configuration changes

drush updatedb -y && drush cex -y

But if you have full drupal site bootstrapped in GitHub action, you could run both of these and commit than

@kevinquillen
Copy link
Author

kevinquillen commented Dec 13, 2023

I can't figure out how to split individual PRs for contrib, but I did get two actions created. One for core only, one for contrib only.

First, the contrib action steps:

      - uses: actions/checkout@v3
      - name: Check for Drupal contributed module updates
        id: updates
        uses: valicm/drupal-update@v4
        with:
          update_core: false
          update_exclude: core, core-recommended, core-composer-scaffold, core-project-message, core-dev
      - name: Get current date and time
        run: |
          echo "JOB_CURRENT_TIME=$(date +'%Y-%m-%d.%s')" >> $GITHUB_ENV
      - name: create pull-request
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.MYSECRET }}
          commit-message: Drupal contrib updates
          title: Drupal contrib updates
          body: ${{ env.DRUPAL_UPDATES_TABLE }}
          branch: updates/drupal-contrib-${{ env.JOB_CURRENT_TIME }}
          delete-branch: true

Secore, core, which does the inverse and uses the exclude input:

      - uses: actions/checkout@v3
      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.1
      - name: Composer install with dev dependencies
        run: composer install -n --optimize-autoloader --ignore-platform-reqs
      - name: Store current version for reference
        run: |
          echo "ORIGINAL_CORE_VERSION=$(composer show drupal/core-recommended | grep "versions : \* [0-9.]" | cut -d' ' -f 4 | xargs -n1 basename)" >> $GITHUB_ENV
      - name: Generating list of contributed modules to exclude from update
        run: |
          echo "CONTRIB_LIST=$(composer show -N -D | grep "drupal/" | cut -d : -f 1 | xargs -n1 basename | grep -v "core-" | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/')" >> $GITHUB_ENV
      - name: Check for Drupal core updates
        run: |
          composer update drupal/core-* -W
      - name: Getting updated version, if applicable
        run: |
          echo "UPDATED_CORE_VERSION=$(composer show drupal/core-recommended | grep "versions : \* [0-9.]" | cut -d' ' -f 4 | xargs -n1 basename)" >> $GITHUB_ENV
      - name: Get current date and time
        run: |
          echo "JOB_CURRENT_TIME=$(date +'%Y-%m-%d.%s')" >> $GITHUB_ENV
      - name: Generate a pull request
        if: ${{ env.ORIGINAL_CORE_VERSION != env.UPDATED_CORE_VERSION }}
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.MYSECRET }}
          commit-message: Update drupal/core-* packages to ${{ env.UPDATED_CORE_VERSION }}
          title: Update drupal/core-* packages to ${{ env.UPDATED_CORE_VERSION }}
          body: |
            Update drupal/core-* packages to ${{ env.UPDATED_CORE_VERSION }}
          branch: release/drupal-core-${{ env.UPDATED_CORE_VERSION }}-${{ env.JOB_CURRENT_TIME }}
          delete-branch: true

I wound up just having the raw composer update command there for simplicity, but the CONTRIB_LIST env variable contains a comma delimited list of all drupal/* packages that are not 'core-'.

  • edit - and yes, the next step is pulling down a database so I can run updates and config export to roll into the PR.

@valicm
Copy link
Owner

valicm commented Dec 14, 2023

You maybe don't need full DB.

Make it so that your installation works with drush si --existing-config

That would bootstrap your site fully, but without the need for you to pull full DB to GitHub actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants