Skip to content

Commit

Permalink
Merge branch 'update_wordpress_js_dependencies_align' into update_wor…
Browse files Browse the repository at this point in the history
…dpress_js_dependencies
  • Loading branch information
luislard committed Feb 5, 2025
2 parents 82950bf + b24d7d4 commit 8a34ccb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -16,7 +16,7 @@ on:
required: true

jobs:
update-dependencies:
update-dependencies-orchestrator:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
Expand All @@ -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=()
Expand All @@ -52,16 +52,13 @@ 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" \
-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
done
19 changes: 8 additions & 11 deletions .github/workflows/update-wordpress-js-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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"
rm -f "${{ runner.temp }}/signingkey.pub"

0 comments on commit 8a34ccb

Please sign in to comment.