From 9001131341dd63ad628dc487796da4086d805e7c Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Mon, 11 Nov 2024 11:09:15 +0100 Subject: [PATCH 01/21] feat: adding automatic WP JS dependencies --- .../update-wordpress-js-dependencies.yml | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 .github/workflows/update-wordpress-js-dependencies.yml diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml new file mode 100644 index 00000000..792ed8e1 --- /dev/null +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -0,0 +1,128 @@ +name: Update WordPress JS Dependencies +on: + workflow_call: + 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 + secrets: + GITHUB_USER_EMAIL: + description: Email address for the GitHub user configuration. + required: false + GITHUB_USER_NAME: + description: Username for the GitHub user configuration. + required: false + GITHUB_USER_SSH_KEY: + description: Private SSH key associated with the GitHub user for the token passed as `GITHUB_USER_TOKEN`. + required: false + GITHUB_USER_SSH_PUBLIC_KEY: + description: Public SSH key associated with the GitHub user for the token passed as `GITHUB_USER_TOKEN`. + required: false + +jobs: + update-dependencies: + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + PACKAGE_MANAGER: npm + GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} + GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} + GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} + WP_SCRIPT_DIST_TAG: ${{ github.event.client_payload.wp_version || inputs.WP_SCRIPT_DIST_TAG }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ssh-key: ${{ env.GITHUB_USER_SSH_KEY }} + + - name: Set global variables + run: | + echo "TEMP_BRANCH_NAME=update/${{ env.WP_SCRIPT_DIST_TAG }}" >> $GITHUB_ENV + echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: Set up SSH + if: ${{ env.GITHUB_USER_SSH_KEY != '' }} + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} + + - name: Set up Git + run: | + git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" + git config --global user.name "${{ env.GITHUB_USER_NAME }}" + git config --global advice.addIgnoredFile false + git config --global push.autoSetupRemote true + + - name: Set up signing commits + if: ${{ env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} + run: | + : # Create empty SSH private key file so Git does not complain. + touch "${{ runner.temp }}/signingkey" + echo "${{ env.GITHUB_USER_SSH_PUBLIC_KEY }}" > "${{ runner.temp }}/signingkey.pub" + git config --global commit.gpgsign true + git config --global gpg.format ssh + git config --global user.signingkey "${{ runner.temp }}/signingkey.pub" + + - name: Checkout to temporary branch + run: | + git show-ref -q refs/remotes/origin/${{ env.TEMP_BRANCH_NAME }} && git checkout ${{ env.TEMP_BRANCH_NAME }} || git checkout -b ${{ env.TEMP_BRANCH_NAME }} + + - name: Set up node cache mode + run: | + if [ "${{ env.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then + echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV + elif [ "${{ env.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then + echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV + else + echo "No lock files found or unknown package manager" + fi + + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: ${{ env.NODE_CACHE_MODE }} + + + - name: Install dependencies + env: + ARGS: ${{ env.NODE_CACHE_MODE == 'yarn' && '--frozen-lockfile' || env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} + run: ${{ format('{0} {1} --ignore-scripts', env.PACKAGE_MANAGER, env.ARGS) }} + + - name: Running the update + env: + SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'yarn' && 'yarn' || env.PACKAGE_MANAGER == 'npm' && 'npm run' }} + run: | + ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_SCRIPT_DIST_TAG }} + + - name: Git add and commit + run: | + git add -A + git commit -m "[BOT] Add dependencies changes for #${{ github.ref }}" --no-verify || ((echo "HAS_GIT_CHANGES=no" >> $GITHUB_ENV) && (echo "No changes to commit")) + + - name: Git push + if: ${{ env.HAS_GIT_CHANGES != 'no' }} + run: git push + + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base ${{ github.event.repository.default_branch }} \ + --head ${{ env.TEMP_BRANCH_NAME }} \ + --title "Align WP Dependencies to meet dist tag ${{ env.WP_SCRIPT_DIST_TAG }} - ${{ env.CURRENT_DATE }}" \ + --body "This PR updates the WordPress dependencies to meet the version ${{ env.WP_SCRIPT_DIST_TAG }}." \ + --label "dependencies" + + - name: Delete signing key files + if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} + run: | + rm -f "${{ runner.temp }}/signingkey" + rm -f "${{ runner.temp }}/signingkey.pub" \ No newline at end of file From 17bc80ae50e24075223fa76e812e2c754a4489fe Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Mon, 11 Nov 2024 14:55:24 +0100 Subject: [PATCH 02/21] chore: improvements --- .../workflows/update-wordpress-js-dependencies.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 792ed8e1..b81b9af0 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -7,6 +7,11 @@ on: default: wp-6.6 required: true type: string + NPM_REGISTRY_DOMAIN: + description: Domain of the private npm registry. + default: https://npm.pkg.github.com/ + required: false + type: string secrets: GITHUB_USER_EMAIL: description: Email address for the GitHub user configuration. @@ -20,6 +25,9 @@ on: GITHUB_USER_SSH_PUBLIC_KEY: description: Public SSH key associated with the GitHub user for the token passed as `GITHUB_USER_TOKEN`. required: false + NPM_REGISTRY_TOKEN: + description: Authentication for the private npm registry. + required: false jobs: update-dependencies: @@ -32,6 +40,8 @@ jobs: GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} WP_SCRIPT_DIST_TAG: ${{ github.event.client_payload.wp_version || inputs.WP_SCRIPT_DIST_TAG }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + NPM_REGISTRY_DOMAIN: "https://npm.pkg.github.com/" steps: - name: Checkout @@ -86,6 +96,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} + registry-url: ${{ env.NPM_REGISTRY_DOMAIN }} cache: ${{ env.NODE_CACHE_MODE }} From 142dd5db0062d66458ba2ee64fb7f57504918692 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Mon, 11 Nov 2024 16:26:10 +0100 Subject: [PATCH 03/21] fix: fixes var names --- .github/workflows/update-wordpress-js-dependencies.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index b81b9af0..dbadc490 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -35,13 +35,13 @@ jobs: timeout-minutes: 10 env: PACKAGE_MANAGER: npm - GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} - GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} - GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} + 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_SCRIPT_DIST_TAG: ${{ github.event.client_payload.wp_version || inputs.WP_SCRIPT_DIST_TAG }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} - NPM_REGISTRY_DOMAIN: "https://npm.pkg.github.com/" + NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} steps: - name: Checkout From 87feea58d2f4457879559c1a66426299a7587e41 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 15 Jan 2025 17:04:32 +0100 Subject: [PATCH 04/21] Adds an orchestrator to trigger js dependencies updates --- ...wordpress-js-dependencies-orchestrator.yml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/update-wordpress-js-dependencies-orchestrator.yml diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml new file mode 100644 index 00000000..65c8e2a0 --- /dev/null +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -0,0 +1,68 @@ +name: Update WordPress JS Dependencies +on: + workflow_call: + inputs: + WP_SCRIPT_DIST_TAG: + description: The tag to use for updating the dependencies. e.g. wp-6.7 + default: wp-6.7 + required: true + type: string + PACKAGES: + description: Comma separated list of packages to call the update js wordpress dependencies. + required: false + type: string + secrets: + GH_API_TOKEN: + description: An GH API Token capable of triggering repository_dispatch. + required: true + +jobs: + update-dependencies: + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + GH_API_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} + WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} + PACKAGES: ${{ inputs.PACKAGES }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Read composer.json and specified packages and call the workflows + run: | + # Initialize an array for packages + packages=() + + # Add packages from composer.json if it exists + if [ -f composer.json ]; then + composer_packages=$(cat composer.json | jq -r '.require | keys[]') + for pkg in $composer_packages; do + packages+=("$pkg") + done + fi + + # Add packages from the PACKAGES environment variable + IFS=',' read -r -a env_packages <<< "$PACKAGES" + for pkg in "${env_packages[@]}"; do + packages+=("$pkg") + done + + # Process all unique packages + unique_packages=$(echo "${packages[@]}" | tr ' ' '\n' | sort -u) + + + for package in "unique_packages"; do + echo "Processing package: $package" + + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ env.GH_API_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$package/dispatches \ + -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_SCRIPT_DIST_TAG }}"}}' + done + \ No newline at end of file From 043a6d537fb194982e157e98e462326aede20aa0 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 15 Jan 2025 17:25:42 +0100 Subject: [PATCH 05/21] Fixes issue in the loop --- .../workflows/update-wordpress-js-dependencies-orchestrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 65c8e2a0..f5972760 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -54,7 +54,7 @@ jobs: unique_packages=$(echo "${packages[@]}" | tr ' ' '\n' | sort -u) - for package in "unique_packages"; do + for package in ${unique_packages[@]}; do echo "Processing package: $package" curl -L \ From 4e6da5015fca1b3dc6e585f8e61cd2103679ad18 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 15 Jan 2025 18:04:43 +0100 Subject: [PATCH 06/21] Fix wrong variable --- .../workflows/update-wordpress-js-dependencies-orchestrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index f5972760..66229b23 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 env: - GH_API_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} + GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} PACKAGES: ${{ inputs.PACKAGES }} From 8f613c9a5963c00e3bc4159e1cff51865dbac5ee Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 22 Jan 2025 12:41:12 +0100 Subject: [PATCH 07/21] docs: add documentation for WP JS Dependencies update workflows --- docs/update-wp-dependencies.md | 112 +++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 docs/update-wp-dependencies.md diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md new file mode 100644 index 00000000..7d943d45 --- /dev/null +++ b/docs/update-wp-dependencies.md @@ -0,0 +1,112 @@ +# Update WP Dependencies + +This workflow is meant to ease the task of updating the **@wordpress/** dependencies. + +We are providing two reusable workflows. + +1. One workflow lives in the package having the dependencies, we will call this "Update WP Dependencies Workflow". +2. The other workflow lives in a package that is meant to orchestrate other packages through composer, we will call this "Update WP Dependencies Orchestrator Workflow". + This is simply a workflow that triggers the other one in other packages. + +## WP Dependencies Update Workflow + +The workflow will create a PR with the updated dependencies. + + +### Configuration parameters + +#### Inputs + +| Name | Default | Description | +|-----------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update)
you can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | +| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | + + +#### Secrets + +| Name | Description | +|------------------------------|------------------------------------------------------------------------------| +| `GITHUB_USER_EMAIL` | Email address for the GitHub user configuration | +| `GITHUB_USER_NAME` | Username for the GitHub user configuration | +| `GITHUB_USER_SSH_KEY` | Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` | +| `GITHUB_USER_SSH_PUBLIC_KEY` | Public SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` | +| `NPM_REGISTRY_TOKEN` | Authentication for the private npm registry | + +**Example with configuration parameters:** + +```yaml +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.7 + default: wp-6.7 + 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@main + secrets: + GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} + GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} + GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} + NPM_REGISTRY_TOKEN: ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN }} + with: + NPM_REGISTRY_DOMAIN: "https://npm.pkg.github.com/" + WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} +``` + +## WP Dependencies Update Orchestrator Workflow + +The workflow will trigger the WP Dependencies Update Workflow in other repositories. + + +### Configuration parameters + +#### Inputs + +| Name | Default | Description | +|-----------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update)
you can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | +| `PACKAGES` | `''` | A comma-separated list of repository in the form of / | + + +#### Secrets + +| Name | Description | +|----------------|---------------------------------------------------| +| `GH_API_TOKEN` | A classic API token with repo and workflow access | + +**Example with configuration parameters:** + +```yaml +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@main + with: + WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} + PACKAGES: ${{ inputs.PACKAGES }} + secrets: + GH_API_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} +``` + From 4f044e294094a55214533725f7e3218b49bab3e8 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 22 Jan 2025 12:59:11 +0100 Subject: [PATCH 08/21] chore: fixing linting issues --- ...wordpress-js-dependencies-orchestrator.yml | 1 - .../update-wordpress-js-dependencies.yml | 3 +- docs/update-wp-dependencies.md | 30 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 66229b23..4507c5cf 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -4,7 +4,6 @@ on: inputs: WP_SCRIPT_DIST_TAG: description: The tag to use for updating the dependencies. e.g. wp-6.7 - default: wp-6.7 required: true type: string PACKAGES: diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index dbadc490..ccdbb62e 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -3,8 +3,7 @@ on: workflow_call: inputs: WP_SCRIPT_DIST_TAG: - description: The tag to use for updating the dependencies. e.g. wp-6.6 - default: wp-6.6 + description: The tag to use for updating the dependencies. e.g. wp-6.7 required: true type: string NPM_REGISTRY_DOMAIN: diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index 7d943d45..2ea67021 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -1,6 +1,6 @@ # Update WP Dependencies -This workflow is meant to ease the task of updating the **@wordpress/** dependencies. +This workflow is meant to ease the task of updating the **@wordpress/name** dependencies. We are providing two reusable workflows. @@ -13,17 +13,17 @@ We are providing two reusable workflows. The workflow will create a PR with the updated dependencies. -### Configuration parameters +### Configuration parameters for WP Dependencies Update Workflow -#### Inputs +#### Inputs for WP Dependencies Update Workflow -| Name | Default | Description | -|-----------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update)
you can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | -| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | +| Name | Default | Description | +|-----------------------|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update). You can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | +| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | -#### Secrets +#### Secrets for WP Dependencies Update Workflow | Name | Description | |------------------------------|------------------------------------------------------------------------------| @@ -67,17 +67,17 @@ jobs: The workflow will trigger the WP Dependencies Update Workflow in other repositories. -### Configuration parameters +### Configuration parameters for WP Dependencies Update Orchestrator Workflow -#### Inputs +#### Inputs for WP Dependencies Update Orchestrator Workflow -| Name | Default | Description | -|-----------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update)
you can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | -| `PACKAGES` | `''` | A comma-separated list of repository in the form of / | +| Name | Default | Description | +|-----------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update). You can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | +| `PACKAGES` | `''` | A comma-separated list of repository in the form of organization-name/repository-name | -#### Secrets +#### Secrets for WP Dependencies Update Orchestrator Workflow | Name | Description | |----------------|---------------------------------------------------| From e0a0233b5fd3f3bd287775a9f7e6138b3ae5cc9d Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Fri, 24 Jan 2025 12:26:37 +0100 Subject: [PATCH 09/21] docs: improve documentation --- docs/update-wp-dependencies.md | 126 +++++++++++++++++---------------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index 2ea67021..b83878e2 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -1,112 +1,118 @@ -# Update WP Dependencies +# Update WordPress JS Dependencies -This workflow is meant to ease the task of updating the **@wordpress/name** dependencies. +This documentation describes two closely related reusable workflows for updating JavaScript +dependencies that use [WordPress packages](https://www.npmjs.com/search?q=%40wordpress%2F). These +workflows handle automatic updates of the `@wordpress/*` packages to a specified WordPress version ( +dist tag) and can optionally create a pull request with all necessary changes. -We are providing two reusable workflows. +1. **Update WordPress JS Dependencies Workflow**: + This workflow lives in an individual repository (the one containing the WordPress JS dependencies + to update). It checks out the repository, updates the `@wordpress/*` dependencies to a specific + tag, and opens a pull request if changes are found. -1. One workflow lives in the package having the dependencies, we will call this "Update WP Dependencies Workflow". -2. The other workflow lives in a package that is meant to orchestrate other packages through composer, we will call this "Update WP Dependencies Orchestrator Workflow". - This is simply a workflow that triggers the other one in other packages. +2. **Update WordPress JS Dependencies Orchestrator Workflow**: + This workflow can be placed in a single "orchestrator" repository (e.g., a website repository). + It triggers the "Update WordPress JS Dependencies Workflow" in multiple other repositories. This + is accomplished by sending + a [repository\_dispatch](https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event) + event to each of the target repositories. -## WP Dependencies Update Workflow +## Update WordPress JS Dependencies Workflow -The workflow will create a PR with the updated dependencies. +This workflow updates the `@wordpress/*` dependencies in the current repository to a specified +WordPress version tag (e.g., `wp-6.7`) and creates a pull request containing all modified files. +### Configuration parameters -### Configuration parameters for WP Dependencies Update Workflow +#### Inputs -#### Inputs for WP Dependencies Update Workflow +| Name | Default | Description | +|-----------------------|---------------------------------|-------------------------------------------------------| +| `WP_VERSION` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | +| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | -| Name | Default | Description | -|-----------------------|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update). You can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | -| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | - - -#### Secrets for WP Dependencies Update Workflow +#### Secrets | Name | Description | |------------------------------|------------------------------------------------------------------------------| +| `NPM_REGISTRY_TOKEN` | Authentication for the private npm registry | | `GITHUB_USER_EMAIL` | Email address for the GitHub user configuration | | `GITHUB_USER_NAME` | Username for the GitHub user configuration | | `GITHUB_USER_SSH_KEY` | Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` | | `GITHUB_USER_SSH_PUBLIC_KEY` | Public SSH key associated with the GitHub user passed as `GITHUB_USER_NAME` | -| `NPM_REGISTRY_TOKEN` | Authentication for the private npm registry | -**Example with configuration parameters:** +### Usage example + +```yml +name: Update WordPress JS Dependencies -```yaml -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.7 - default: wp-6.7 + WP_VERSION: + description: 'The tag to update the dependencies to, e.g., `wp-6.7`.' + default: 'wp-6.7' required: true type: string repository_dispatch: - types: ['update_wp_dependencies'] + types: [ 'update_wp_dependencies' ] jobs: - update_wp_dependencies: - uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies.yml@main - secrets: - GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} - GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} - GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} - GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} - NPM_REGISTRY_TOKEN: ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN }} - with: - NPM_REGISTRY_DOMAIN: "https://npm.pkg.github.com/" - WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} + update-dependencies: + uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies.yml@main + secrets: + GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} + GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} + GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} + NPM_REGISTRY_TOKEN: ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN }} + with: + WP_VERSION: ${{ inputs.WP_VERSION }} ``` -## WP Dependencies Update Orchestrator Workflow - -The workflow will trigger the WP Dependencies Update Workflow in other repositories. - +## Update WordPress JS Dependencies Orchestrator Workflow -### Configuration parameters for WP Dependencies Update Orchestrator Workflow +This workflow triggers the “Update WordPress JS Dependencies Workflow” in multiple external +repositories by sending a `repository_dispatch` event to each target repository. This allows you to +maintain a centralized list of repositories needing consistent WordPress JS dependency versions. -#### Inputs for WP Dependencies Update Orchestrator Workflow +### Configuration parameters -| Name | Default | Description | -|-----------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `WP_SCRIPT_DIST_TAG` | `'wp-6.7'` | The dist tag used by [wp-scripts packages-update](https://github.com/WordPress/gutenberg/tree/trunk/packages/scripts#packages-update). You can see which tags are available by going to any [WordPress Package in NPM](https://www.npmjs.com/package/@wordpress/blocks?activeTab=versions) and see the Tag column | -| `PACKAGES` | `''` | A comma-separated list of repository in the form of organization-name/repository-name | +#### Inputs +| Name | Default | Description | +|--------------|------------|----------------------------------------------------------------| +| `WP_VERSION` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | +| `PACKAGES` | `''` | Comma-separated list of additional `owner/repo`s to be updated | -#### Secrets for WP Dependencies Update Orchestrator Workflow +#### Secrets -| Name | Description | -|----------------|---------------------------------------------------| -| `GH_API_TOKEN` | A classic API token with repo and workflow access | +| Name | Description | +|----------------|-------------------------------------------------------------------------------------------------------------------------| +| `GH_API_TOKEN` | A personal access token (classic) with `repo` and `workflow` permissions, used to authenticate when calling GitHub APIs | -**Example with configuration parameters:** +### Usage example -```yaml -name: Call Update WordPress Deps using loop from composer and defined packages +```yml +name: Update WordPress JS Dependencies Orchestrator on: workflow_dispatch: inputs: - WP_SCRIPT_DIST_TAG: - description: 'The WP dist tag. e.g.: wp-6.7' + WP_VERSION: + description: 'The tag to update the dependencies to, e.g., `wp-6.7`' required: true PACKAGES: - description: Comma separated list of packages to call the update js wordpress dependencies. + description: 'Comma-separated list of additional `owner/repo`s to be updated.' required: false type: string - jobs: - update-dependencies: + update-dependency-orchestrator: uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml@main with: - WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} + WP_VERSION: ${{ inputs.WP_VERSION }} PACKAGES: ${{ inputs.PACKAGES }} secrets: GH_API_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} ``` - From fd9e688dd520ac3cf6951e62ad5999dceb979814 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Fri, 24 Jan 2025 12:34:44 +0100 Subject: [PATCH 10/21] fix: silence QA error --- docs/update-wp-dependencies.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index b83878e2..c964ccd8 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -1,3 +1,5 @@ + + # Update WordPress JS Dependencies This documentation describes two closely related reusable workflows for updating JavaScript From 82950bf8a756825af4a803eec845f5aac37a7a9f Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 5 Feb 2025 12:21:13 +0100 Subject: [PATCH 11/21] Update .github/workflows/update-wordpress-js-dependencies-orchestrator.yml Co-authored-by: Philipp Bammes <8144115+tyrann0us@users.noreply.github.com> Signed-off-by: Luis Rosales --- .../workflows/update-wordpress-js-dependencies-orchestrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 4507c5cf..0e3d93aa 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -1,4 +1,4 @@ -name: Update WordPress JS Dependencies +name: Update WordPress JS Dependencies Orchestrator on: workflow_call: inputs: From df61100e5ac4aeb5d6f228cd26a0c0e46e7a813d Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 5 Feb 2025 12:42:43 +0100 Subject: [PATCH 12/21] chore: test GITHUB_TOKEN --- .../update-wordpress-js-dependencies-orchestrator.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 4507c5cf..16be78bb 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -3,11 +3,11 @@ on: workflow_call: inputs: WP_SCRIPT_DIST_TAG: - description: The tag to use for updating the dependencies. e.g. wp-6.7 + description: The dist-tag to update the dependencies to, e.g., `wp-6.7` required: true type: string PACKAGES: - description: Comma separated list of packages to call the update js wordpress dependencies. + description: Comma-separated list of additional `owner/repo`s to be updated. required: false type: string secrets: @@ -16,7 +16,7 @@ on: required: true jobs: - update-dependencies: + update-dependencies-orchestrator: runs-on: ubuntu-latest timeout-minutes: 10 env: @@ -59,7 +59,7 @@ jobs: curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ env.GH_API_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$package/dispatches \ -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_SCRIPT_DIST_TAG }}"}}' From 00709cc5c97e71d499aec2f562623865c64c50a0 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 5 Feb 2025 12:59:28 +0100 Subject: [PATCH 13/21] chore: revert variable --- .../workflows/update-wordpress-js-dependencies-orchestrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 16be78bb..5c744af9 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -59,7 +59,7 @@ jobs: curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: Bearer ${{ env.GH_API_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$package/dispatches \ -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_SCRIPT_DIST_TAG }}"}}' From b24d7d4fca3adae62aae682e8af7508e3fd47b4f Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Wed, 5 Feb 2025 14:19:43 +0100 Subject: [PATCH 14/21] chore: align with PR change requests --- ...wordpress-js-dependencies-orchestrator.yml | 7 ++----- .../update-wordpress-js-dependencies.yml | 19 ++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 5c744af9..fe9cadd6 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -30,7 +30,7 @@ jobs: with: fetch-depth: 0 - - name: Read composer.json and specified packages and call the workflows + - name: Gather packages and call the individual workflows. run: | # Initialize an array for packages packages=() @@ -52,10 +52,8 @@ jobs: # Process all unique packages unique_packages=$(echo "${packages[@]}" | tr ' ' '\n' | sort -u) - for package in ${unique_packages[@]}; do echo "Processing package: $package" - curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ @@ -63,5 +61,4 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$package/dispatches \ -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_SCRIPT_DIST_TAG }}"}}' - done - \ No newline at end of file + done \ No newline at end of file diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index ccdbb62e..2d091182 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_SCRIPT_DIST_TAG: - description: The tag to use for updating the dependencies. e.g. wp-6.7 + description: The dist-tag to update the dependencies to, e.g., `wp-6.7` required: true type: string NPM_REGISTRY_DOMAIN: @@ -85,8 +85,6 @@ jobs: run: | if [ "${{ env.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV - elif [ "${{ env.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then - echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV else echo "No lock files found or unknown package manager" fi @@ -101,26 +99,25 @@ jobs: - name: Install dependencies env: - ARGS: ${{ env.NODE_CACHE_MODE == 'yarn' && '--frozen-lockfile' || env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} + ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} run: ${{ format('{0} {1} --ignore-scripts', env.PACKAGE_MANAGER, env.ARGS) }} - name: Running the update env: - SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'yarn' && 'yarn' || env.PACKAGE_MANAGER == 'npm' && 'npm run' }} + SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'npm' && 'npm run' }} run: | ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_SCRIPT_DIST_TAG }} - - name: Git add and commit + - name: Git add, commit run: | git add -A - git commit -m "[BOT] Add dependencies changes for #${{ github.ref }}" --no-verify || ((echo "HAS_GIT_CHANGES=no" >> $GITHUB_ENV) && (echo "No changes to commit")) + git commit -m "[BOT] Add dependencies changes for #${{ github.ref }}" --no-verify || ((echo "NO_CHANGES=yes" >> $GITHUB_ENV) && (echo "No changes to commit")) - name: Git push - if: ${{ env.HAS_GIT_CHANGES != 'no' }} + if: ${{ env.NO_CHANGES != 'yes' }} run: git push - - - name: Create Pull Request + - name: Create pull request env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -135,4 +132,4 @@ jobs: if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} run: | rm -f "${{ runner.temp }}/signingkey" - rm -f "${{ runner.temp }}/signingkey.pub" \ No newline at end of file + rm -f "${{ runner.temp }}/signingkey.pub" From 3a6d55d0b37fc632bf9f0f2a88dd4cf3e3a8ad37 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Thu, 6 Feb 2025 17:10:54 +0100 Subject: [PATCH 15/21] chore: align with PR comments --- ...te-wordpress-js-dependencies-orchestrator.yml | 14 +++++++------- .../update-wordpress-js-dependencies.yml | 12 ++++++------ docs/update-wp-dependencies.md | 16 ++++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 2c2c1b29..47a56b4d 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -2,7 +2,7 @@ name: Update WordPress JS Dependencies Orchestrator on: workflow_call: inputs: - WP_SCRIPT_DIST_TAG: + WP_DIST_TAG: description: The dist-tag to update the dependencies to, e.g., `wp-6.7` required: true type: string @@ -11,8 +11,8 @@ on: required: false type: string secrets: - GH_API_TOKEN: - description: An GH API Token capable of triggering repository_dispatch. + GH_TOKEN: + description: A personal access token (classic) with `repo` and `workflow` permissions, used to authenticate when calling GitHub APIs in target repositories. required: true jobs: @@ -20,8 +20,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 env: - GH_API_TOKEN: ${{ secrets.GH_API_TOKEN }} - WP_SCRIPT_DIST_TAG: ${{ inputs.WP_SCRIPT_DIST_TAG }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + WP_DIST_TAG: ${{ inputs.WP_DIST_TAG }} PACKAGES: ${{ inputs.PACKAGES }} steps: @@ -57,8 +57,8 @@ jobs: curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ env.GH_API_TOKEN }}" \ + -H "Authorization: Bearer ${{ env.GH_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$package/dispatches \ - -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_SCRIPT_DIST_TAG }}"}}' + -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_DIST_TAG }}"}}' done \ No newline at end of file diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 2d091182..f1bf4217 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -2,7 +2,7 @@ name: Update WordPress JS Dependencies on: workflow_call: inputs: - WP_SCRIPT_DIST_TAG: + WP_DIST_TAG: description: The dist-tag to update the dependencies to, e.g., `wp-6.7` required: true type: string @@ -38,7 +38,7 @@ jobs: 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_SCRIPT_DIST_TAG: ${{ github.event.client_payload.wp_version || inputs.WP_SCRIPT_DIST_TAG }} + WP_DIST_TAG: ${{ github.event.client_payload.wp_version || inputs.WP_DIST_TAG }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} @@ -51,7 +51,7 @@ jobs: - name: Set global variables run: | - echo "TEMP_BRANCH_NAME=update/${{ env.WP_SCRIPT_DIST_TAG }}" >> $GITHUB_ENV + echo "TEMP_BRANCH_NAME=update/${{ env.WP_DIST_TAG }}" >> $GITHUB_ENV echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Set up SSH @@ -106,7 +106,7 @@ jobs: env: SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'npm' && 'npm run' }} run: | - ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_SCRIPT_DIST_TAG }} + ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_DIST_TAG }} - name: Git add, commit run: | @@ -124,8 +124,8 @@ jobs: gh pr create \ --base ${{ github.event.repository.default_branch }} \ --head ${{ env.TEMP_BRANCH_NAME }} \ - --title "Align WP Dependencies to meet dist tag ${{ env.WP_SCRIPT_DIST_TAG }} - ${{ env.CURRENT_DATE }}" \ - --body "This PR updates the WordPress dependencies to meet the version ${{ env.WP_SCRIPT_DIST_TAG }}." \ + --title "Align WP Dependencies to meet dist tag ${{ env.WP_DIST_TAG }} - ${{ env.CURRENT_DATE }}" \ + --body "This PR updates the WordPress dependencies to meet the version ${{ env.WP_DIST_TAG }}." \ --label "dependencies" - name: Delete signing key files diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index c964ccd8..62582733 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -30,7 +30,7 @@ WordPress version tag (e.g., `wp-6.7`) and creates a pull request containing all | Name | Default | Description | |-----------------------|---------------------------------|-------------------------------------------------------| -| `WP_VERSION` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | +| `WP_DIST_TAG` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | | `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | #### Secrets @@ -51,7 +51,7 @@ name: Update WordPress JS Dependencies on: workflow_dispatch: inputs: - WP_VERSION: + WP_DIST_TAG: description: 'The tag to update the dependencies to, e.g., `wp-6.7`.' default: 'wp-6.7' required: true @@ -69,7 +69,7 @@ jobs: GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.DEPLOYBOT_SSH_PUBLIC_KEY }} NPM_REGISTRY_TOKEN: ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN }} with: - WP_VERSION: ${{ inputs.WP_VERSION }} + WP_DIST_TAG: ${{ inputs.WP_DIST_TAG }} ``` ## Update WordPress JS Dependencies Orchestrator Workflow @@ -84,14 +84,14 @@ maintain a centralized list of repositories needing consistent WordPress JS depe | Name | Default | Description | |--------------|------------|----------------------------------------------------------------| -| `WP_VERSION` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | +| `WP_DIST_TAG` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | | `PACKAGES` | `''` | Comma-separated list of additional `owner/repo`s to be updated | #### Secrets | Name | Description | |----------------|-------------------------------------------------------------------------------------------------------------------------| -| `GH_API_TOKEN` | A personal access token (classic) with `repo` and `workflow` permissions, used to authenticate when calling GitHub APIs | +| `GH_TOKEN` | A personal access token (classic) with `repo` and `workflow` permissions, used to authenticate when calling GitHub APIs | ### Usage example @@ -101,7 +101,7 @@ name: Update WordPress JS Dependencies Orchestrator on: workflow_dispatch: inputs: - WP_VERSION: + WP_DIST_TAG: description: 'The tag to update the dependencies to, e.g., `wp-6.7`' required: true PACKAGES: @@ -113,8 +113,8 @@ jobs: update-dependency-orchestrator: uses: inpsyde/reusable-workflows/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml@main with: - WP_VERSION: ${{ inputs.WP_VERSION }} + WP_DIST_TAG: ${{ inputs.WP_DIST_TAG }} PACKAGES: ${{ inputs.PACKAGES }} secrets: - GH_API_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} + GH_TOKEN: ${{ secrets.DEPLOYBOT_REPO_READ_WRITE_TOKEN }} ``` From 4f16a51f48e791059c67c8c606bb1f47ebb59403 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Thu, 6 Feb 2025 17:23:15 +0100 Subject: [PATCH 16/21] chore: add changes to orchestrator --- .../update-wordpress-js-dependencies-orchestrator.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 47a56b4d..7594b22b 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_DIST_TAG: - description: The dist-tag to update the dependencies to, e.g., `wp-6.7` + description: The dist tag to update the dependencies to, e.g., `wp-6.7` required: true type: string PACKAGES: @@ -61,4 +61,5 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$package/dispatches \ -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_DIST_TAG }}"}}' - done \ No newline at end of file + done + \ No newline at end of file From 0de8c4e6e2293f66f1c9394e340141a3b9101662 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Mon, 10 Feb 2025 14:45:11 +0100 Subject: [PATCH 17/21] chore: switch approach to use workflow run --- .../update-wordpress-js-dependencies-orchestrator.yml | 11 +++-------- .../workflows/update-wordpress-js-dependencies.yml | 2 +- docs/update-wp-dependencies.md | 2 -- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 7594b22b..80395297 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -54,12 +54,7 @@ jobs: for package in ${unique_packages[@]}; do echo "Processing package: $package" - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ env.GH_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/$package/dispatches \ - -d '{"event_type":"update_wp_dependencies","client_payload":{"wp_version":"${{ env.WP_DIST_TAG }}"}}' + gh workflow run update-wordpress-js-dependencies.yml \ + --repo $package \ + --field WP_DIST_TAG=${{ env.WP_DIST_TAG }} done - \ No newline at end of file diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index f1bf4217..554bee97 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -38,7 +38,7 @@ jobs: 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: ${{ github.event.client_payload.wp_version || inputs.WP_DIST_TAG }} + WP_DIST_TAG: ${{ inputs.WP_DIST_TAG }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index 62582733..fc52df41 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -56,8 +56,6 @@ on: default: 'wp-6.7' required: true type: string - repository_dispatch: - types: [ 'update_wp_dependencies' ] jobs: update-dependencies: From 29d31179f5203148936156f6bab04e56b6373478 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Tue, 1 Apr 2025 10:09:07 +0200 Subject: [PATCH 18/21] chore(docs): fix several minor issues and align documentation --- .../update-wordpress-js-dependencies.yml | 5 ++-- docs/update-wp-dependencies.md | 30 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 554bee97..315872e5 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_DIST_TAG: - description: The dist-tag to update the dependencies to, e.g., `wp-6.7` + description: The dist tag to update the dependencies to, e.g., `wp-6.7` required: true type: string NPM_REGISTRY_DOMAIN: @@ -96,13 +96,12 @@ jobs: registry-url: ${{ env.NPM_REGISTRY_DOMAIN }} cache: ${{ env.NODE_CACHE_MODE }} - - name: Install dependencies env: ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} run: ${{ format('{0} {1} --ignore-scripts', env.PACKAGE_MANAGER, env.ARGS) }} - - name: Running the update + - name: Update dependencies env: SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'npm' && 'npm run' }} run: | diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index fc52df41..0f32822c 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -8,16 +8,10 @@ workflows handle automatic updates of the `@wordpress/*` packages to a specified dist tag) and can optionally create a pull request with all necessary changes. 1. **Update WordPress JS Dependencies Workflow**: - This workflow lives in an individual repository (the one containing the WordPress JS dependencies - to update). It checks out the repository, updates the `@wordpress/*` dependencies to a specific - tag, and opens a pull request if changes are found. + This workflow lives in an individual repository (the one containing the WordPress JS dependencies to update). It checks out the repository, updates the `@wordpress/*` dependencies to a specific tag, and opens a pull request if changes are found. 2. **Update WordPress JS Dependencies Orchestrator Workflow**: - This workflow can be placed in a single "orchestrator" repository (e.g., a website repository). - It triggers the "Update WordPress JS Dependencies Workflow" in multiple other repositories. This - is accomplished by sending - a [repository\_dispatch](https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event) - event to each of the target repositories. + This workflow can be placed in a single "orchestrator" repository (e.g., a website repository). It triggers the "Update WordPress JS Dependencies Workflow" in multiple other repositories. This is accomplished by sending a [workflow\_dispatch](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch) event to each of the target repositories. ## Update WordPress JS Dependencies Workflow @@ -28,10 +22,10 @@ WordPress version tag (e.g., `wp-6.7`) and creates a pull request containing all #### Inputs -| Name | Default | Description | -|-----------------------|---------------------------------|-------------------------------------------------------| -| `WP_DIST_TAG` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | -| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | +| Name | Default | Description | +|-----------------------|---------------------------------|------------------------------------------------------------| +| `WP_DIST_TAG` | `'wp-6.7'` | The dist tag to update the dependencies to, e.g., `wp-6.7` | +| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry | #### Secrets @@ -52,7 +46,7 @@ on: workflow_dispatch: inputs: WP_DIST_TAG: - description: 'The tag to update the dependencies to, e.g., `wp-6.7`.' + description: The dist tag to update the dependencies to, e.g., `wp-6.7`. default: 'wp-6.7' required: true type: string @@ -80,10 +74,10 @@ maintain a centralized list of repositories needing consistent WordPress JS depe #### Inputs -| Name | Default | Description | -|--------------|------------|----------------------------------------------------------------| -| `WP_DIST_TAG` | `'wp-6.7'` | The tag to update the dependencies to, e.g., `wp-6.7` | -| `PACKAGES` | `''` | Comma-separated list of additional `owner/repo`s to be updated | +| Name | Default | Description | +|---------------|------------|----------------------------------------------------------------| +| `WP_DIST_TAG` | `'wp-6.7'` | The dist tag to update the dependencies to, e.g., `wp-6.7` | +| `PACKAGES` | `''` | Comma-separated list of additional `owner/repo`s to be updated | #### Secrets @@ -100,7 +94,7 @@ on: workflow_dispatch: inputs: WP_DIST_TAG: - description: 'The tag to update the dependencies to, e.g., `wp-6.7`' + description: The dist tag to update the dependencies to, e.g., `wp-6.7` required: true PACKAGES: description: 'Comma-separated list of additional `owner/repo`s to be updated.' From 1e900d37f0a333f6d1bcd0505dc830fa50317278 Mon Sep 17 00:00:00 2001 From: Philipp Bammes Date: Tue, 1 Apr 2025 10:30:22 +0200 Subject: [PATCH 19/21] chore: formatting --- ...te-wordpress-js-dependencies-orchestrator.yml | 2 +- .../update-wordpress-js-dependencies.yml | 2 +- docs/update-wp-dependencies.md | 16 +++++----------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 80395297..755f3f00 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_DIST_TAG: - description: The dist tag to update the dependencies to, e.g., `wp-6.7` + description: The dist tag to update the dependencies to, e.g., `wp-6.7`. required: true type: string PACKAGES: diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 315872e5..250e116a 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_DIST_TAG: - description: The dist tag to update the dependencies to, e.g., `wp-6.7` + description: The dist tag to update the dependencies to, e.g., `wp-6.7`. required: true type: string NPM_REGISTRY_DOMAIN: diff --git a/docs/update-wp-dependencies.md b/docs/update-wp-dependencies.md index 0f32822c..10def1d1 100644 --- a/docs/update-wp-dependencies.md +++ b/docs/update-wp-dependencies.md @@ -2,10 +2,7 @@ # Update WordPress JS Dependencies -This documentation describes two closely related reusable workflows for updating JavaScript -dependencies that use [WordPress packages](https://www.npmjs.com/search?q=%40wordpress%2F). These -workflows handle automatic updates of the `@wordpress/*` packages to a specified WordPress version ( -dist tag) and can optionally create a pull request with all necessary changes. +This documentation describes two closely related reusable workflows for updating JavaScript dependencies that use [WordPress packages](https://www.npmjs.com/search?q=%40wordpress%2F). These workflows handle automatic updates of the `@wordpress/*` packages to a specified WordPress version (dist tag) and can optionally create a pull request with all necessary changes. 1. **Update WordPress JS Dependencies Workflow**: This workflow lives in an individual repository (the one containing the WordPress JS dependencies to update). It checks out the repository, updates the `@wordpress/*` dependencies to a specific tag, and opens a pull request if changes are found. @@ -15,8 +12,7 @@ dist tag) and can optionally create a pull request with all necessary changes. ## Update WordPress JS Dependencies Workflow -This workflow updates the `@wordpress/*` dependencies in the current repository to a specified -WordPress version tag (e.g., `wp-6.7`) and creates a pull request containing all modified files. +This workflow updates the `@wordpress/*` dependencies in the current repository to a specified WordPress version tag (e.g., `wp-6.7`) and creates a pull request containing all modified files. ### Configuration parameters @@ -66,9 +62,7 @@ jobs: ## Update WordPress JS Dependencies Orchestrator Workflow -This workflow triggers the “Update WordPress JS Dependencies Workflow” in multiple external -repositories by sending a `repository_dispatch` event to each target repository. This allows you to -maintain a centralized list of repositories needing consistent WordPress JS dependency versions. +This workflow triggers the “Update WordPress JS Dependencies Workflow” in multiple external repositories by sending a `repository_dispatch` event to each target repository. This allows you to maintain a centralized list of repositories needing consistent WordPress JS dependency versions. ### Configuration parameters @@ -81,8 +75,8 @@ maintain a centralized list of repositories needing consistent WordPress JS depe #### Secrets -| Name | Description | -|----------------|-------------------------------------------------------------------------------------------------------------------------| +| Name | Description | +|------------|-------------------------------------------------------------------------------------------------------------------------| | `GH_TOKEN` | A personal access token (classic) with `repo` and `workflow` permissions, used to authenticate when calling GitHub APIs | ### Usage example From 22c3441428c36b04e538c8c3b2a19c144ef8cbcb Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Tue, 1 Apr 2025 11:53:57 +0200 Subject: [PATCH 20/21] chore: refactor env vars from global scope to step scope and minor documentation aligments --- ...wordpress-js-dependencies-orchestrator.yml | 2 +- .../update-wordpress-js-dependencies.yml | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml index 755f3f00..80395297 100644 --- a/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml +++ b/.github/workflows/update-wordpress-js-dependencies-orchestrator.yml @@ -3,7 +3,7 @@ on: workflow_call: inputs: WP_DIST_TAG: - description: The dist tag to update the dependencies to, e.g., `wp-6.7`. + description: The dist tag to update the dependencies to, e.g., `wp-6.7` required: true type: string PACKAGES: diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 250e116a..008b68bb 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -34,20 +34,14 @@ jobs: timeout-minutes: 10 env: 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 }} steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - ssh-key: ${{ env.GITHUB_USER_SSH_KEY }} + ssh-key: ${{ secrets.GITHUB_USER_SSH_KEY }} - name: Set global variables run: | @@ -55,12 +49,17 @@ jobs: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Set up SSH + env: + GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }} if: ${{ env.GITHUB_USER_SSH_KEY != '' }} uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - name: Set up Git + env: + GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }} + GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }} run: | git config --global user.email "${{ env.GITHUB_USER_EMAIL }}" git config --global user.name "${{ env.GITHUB_USER_NAME }}" @@ -68,6 +67,8 @@ jobs: git config --global push.autoSetupRemote true - name: Set up signing commits + env: + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} if: ${{ env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} run: | : # Create empty SSH private key file so Git does not complain. @@ -90,6 +91,9 @@ jobs: fi - name: Set up node + env: + NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} @@ -99,11 +103,15 @@ jobs: - name: Install dependencies env: ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} + NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} run: ${{ format('{0} {1} --ignore-scripts', env.PACKAGE_MANAGER, env.ARGS) }} - name: Update dependencies env: SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'npm' && 'npm run' }} + NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} run: | ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_DIST_TAG }} @@ -128,6 +136,8 @@ jobs: --label "dependencies" - name: Delete signing key files + env: + GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }} if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }} run: | rm -f "${{ runner.temp }}/signingkey" From 4f3339ac88ffe03716a394573e0f673a3438dd75 Mon Sep 17 00:00:00 2001 From: Luis Rosales Date: Tue, 1 Apr 2025 12:03:49 +0200 Subject: [PATCH 21/21] chore: fix lint issues --- .github/workflows/update-wordpress-js-dependencies.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-wordpress-js-dependencies.yml b/.github/workflows/update-wordpress-js-dependencies.yml index 008b68bb..c1055e7c 100644 --- a/.github/workflows/update-wordpress-js-dependencies.yml +++ b/.github/workflows/update-wordpress-js-dependencies.yml @@ -92,7 +92,7 @@ jobs: - name: Set up node env: - NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} uses: actions/setup-node@v4 with: @@ -103,14 +103,14 @@ jobs: - name: Install dependencies env: ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }} - NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} run: ${{ format('{0} {1} --ignore-scripts', env.PACKAGE_MANAGER, env.ARGS) }} - name: Update dependencies env: SCRIPT_START: ${{ env.PACKAGE_MANAGER == 'npm' && 'npm run' }} - NPM_REGISTRY_DOMAIN: ${{ secrets.NPM_REGISTRY_DOMAIN }} + NPM_REGISTRY_DOMAIN: ${{ inputs.NPM_REGISTRY_DOMAIN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} run: | ./node_modules/.bin/wp-scripts packages-update --dist-tag=${{ env.WP_DIST_TAG }}