Skip to content

Conversation

luislard
Copy link
Contributor

@luislard luislard commented Jan 15, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature

What is the current behavior? (You can also link to an open issue here)
There is no workflow to automatically create a PR with updated WordPress dependencies.

What is the new behavior (if this is a feature change)?
It adds two new workflows to create a PR with updated WordPress dependencies.

The reusable workflow for the orchestrator was added in here:

reusable-workflows/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml at update_wordpress_js_dependencies · inpsyde/reusable-workflows

How does it work?

Individual package

The workflow can be called from the individual package or from the orchestrator.

Example:

name: WordPress JS Dependencies Update
on:
  workflow_dispatch:
    inputs:
      WP_SCRIPT_DIST_TAG:
        description: The tag to use for updating the dependencies. e.g. wp-6.6
        default: wp-6.6
        required: true
        type: string
  repository_dispatch:
    types: ['update_wp_dependencies']

jobs:
  update_wp_dependencies:
    uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies.yml@update_wordpress_js_dependencies
    secrets:
        GITHUB_USER_EMAIL: ${{ secrets.SOME_EMAIL }}
        GITHUB_USER_NAME: ${{ secrets.SOME_USER }}
        GITHUB_USER_SSH_KEY: ${{ secrets.SOME_SSH_PRIVATE_KEY }}
        GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.SOME_SSH_PUBLIC_KEY }}
        NPM_REGISTRY_TOKEN: ${{ secrets.SOME_TOKEN }}
    with:
        NPM_REGISTRY_DOMAIN: "https://npm.pkg.github.com/"
        WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }}

Orchestrator

An orchestrator is a repository that consumes other packages, typically a website repository.

Orchestrator example:

name: Call Update WordPress Deps using loop from composer and defined packages 

on:
  workflow_dispatch:
    inputs:
      WP_SCRIPT_DIST_TAG:
        description: 'The WP dist tag. e.g.: wp-6.7'
        required: true
      PACKAGES:
        description: Comma separated list of packages to call the update js wordpress dependencies.
        required: false
        type: string
  

jobs:
  update-dependencies:
    uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml@update_wordpress_js_dependencies
    with:
      WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }}
      PACKAGES: ${{ inputs.PACKAGES }}
    secrets:
      GH_API_TOKEN: ${{ secrets.SOME_TOKEN }}

The workflow is triggered on demand. The user needs to define the wp dist tag and could optionally define some repos in the PACKAGES input in a comma-separated string.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No

Other information:

@luislard luislard marked this pull request as ready for review January 22, 2025 12:00
@luislard luislard requested a review from a team as a code owner January 22, 2025 12:00
@tyrann0us tyrann0us changed the title Update wordpress js dependencies Update WordPress JS dependencies Jan 22, 2025
@Chrico Chrico requested a review from tyrann0us January 22, 2025 13:53
Copy link
Member

@tyrann0us tyrann0us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this workflow! I left a couple of minor suggestions and comments.
Also, I took the liberty to push a rather major rewrite of the documentation; putting this into line suggestions would have been impossible.
Please check my comments and the updated documentation. Thank you!

Copy link
Member

@tyrann0us tyrann0us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for incorporating all the changes, and I apologize for the number of new comments. Most are minor, as they are about documentation wording alignment or previously overlooked suggestions, but there's one regarding the documentation that does not reflect the move from repository_dispatch to workflow_dispatch.
This should be the last round. 🤞🏽

Comment on lines 36 to 43
PACKAGE_MANAGER: npm
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }}
GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }}
WP_DIST_TAG: ${{ inputs.WP_DIST_TAG }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime, #180 has been merged. Please validate which global env variables are still needed here and which can be moved to step level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left only non secrets

- name: Set up Git
env:
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest change made me realize that an if check is missing here because these credentials are optional.

Suggested change
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }}

Comment on lines +106 to +107
NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that NPM_REGISTRY_DOMAIN and NODE_AUTH_TOKEN are indeed required again here and in the "Update dependencies" step below? I would expect this to be similar to Composer's COMPOSER_AUTH variable, which is only required once.

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

Successfully merging this pull request may close these issues.

3 participants