-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate-wordpress-js-dependencies-orchestrator.yml
More file actions
67 lines (57 loc) · 2.09 KB
/
update-wordpress-js-dependencies-orchestrator.yml
File metadata and controls
67 lines (57 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Update WordPress JS Dependencies Orchestrator
on:
workflow_call:
inputs:
WP_SCRIPT_DIST_TAG:
description: The tag to use for updating the dependencies. e.g. 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.GH_API_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