Skip to content

Commit 33f461f

Browse files
committed
Some test changes.
1 parent 5599da7 commit 33f461f

2 files changed

Lines changed: 26 additions & 75 deletions

File tree

.github/workflows/check-built-files.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
# runs for pull requests.
77
#
88
# Other workflows that run on push will detect changes to versioned files and fail.
9-
pull_request_target:
9+
pull_request:
1010
branches:
1111
- trunk
1212
- '6.[8-9]'
@@ -31,7 +31,7 @@ on:
3131
concurrency:
3232
# The concurrency group contains the workflow name and the branch name for pull requests
3333
# or the commit hash for any other events.
34-
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.sha }}
34+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
3535
cancel-in-progress: true
3636

3737
# Disable permissions for all available scopes by default.
@@ -41,11 +41,6 @@ permissions: {}
4141
jobs:
4242
update-built-files:
4343
name: Update built files
44-
permissions:
45-
contents: write
46-
pull-requests: write
47-
# This should never be changed to use local reference. Always reference the workflow in trunk.
48-
uses: desrosj/wordpress-develop/.github/workflows/reusable-check-built-files.yml@trunk
49-
secrets:
50-
GH_APP_ID: ${{ secrets.GH_APP_ID }}
51-
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
44+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
45+
uses: ./.github/workflows/reusable-check-built-files.yml
46+
Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
name: Lint GitHub Actions workflows
22
on:
33
workflow_call:
4-
secrets:
5-
GH_APP_ID:
6-
description: 'A GitHub App ID.'
7-
required: true
8-
GH_APP_PRIVATE_KEY:
9-
description: 'A GitHub App private key.'
10-
required: true
114

125
permissions: {}
136

147
jobs:
158
# Checks a PR for uncommitted changes to built files.
169
#
17-
# This job uses a GitHub App instead of $GITHUB_TOKEN because Dependabot pull requests are only granted
18-
# read-only access.
10+
# When changes are detected, the patch and PR number are stored as an artifact for the Commit Built File Changes
11+
# workflow to commit and push the changes back for testing.
1912
#
2013
# Performs the following steps:
21-
# - Generates a token for authenticating with the GitHub App.
2214
# - Checks out the repository.
2315
# - Sets up Node.js.
2416
# - Configures caching for Composer.
@@ -31,63 +23,22 @@ jobs:
3123
# - Builds WordPress.
3224
# - Checks for changes to versioned files.
3325
# - Displays the result of git diff for debugging purposes.
34-
# - Configures the Git author.
35-
# - Stages changes.
36-
# - Commits changes.
37-
# - Pushes changes.
26+
# - Creates a directory for storing PR data.
27+
# - Saves the patch as a file.
28+
# - Saves the PR number to a file.
29+
# - Uploads the PR data as an artifact.
3830
update-built-files:
3931
name: Check and update built files
4032
runs-on: ubuntu-24.04
4133
# This prevents an unnecessary second run after changes are committed back because Dependabot always rebases
4234
# updates and force pushes.
4335
if: ${{ github.actor != 'dependabot[bot]' || github.event.commits < 2 }}
4436
timeout-minutes: 10
45-
permissions:
46-
contents: write
47-
pull-requests: write
4837
steps:
49-
- name: Generate Installation Token
50-
id: generate_token
51-
env:
52-
GH_APP_ID: ${{ secrets.GH_APP_ID }}
53-
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
54-
run: |
55-
echo "$GH_APP_PRIVATE_KEY" > private-key.pem
56-
57-
# Generate JWT
58-
JWT=$(python3 - <<EOF
59-
import jwt, time
60-
private_key = open("private-key.pem", "r").read()
61-
payload = {
62-
"iat": int(time.time()),
63-
"exp": int(time.time()) + 60, # 10-minute expiration
64-
"iss": $GH_APP_ID
65-
}
66-
print(jwt.encode(payload, private_key, algorithm="RS256"))
67-
EOF
68-
)
69-
70-
# Get Installation ID
71-
INSTALLATION_ID=$(curl -s -X GET -H "Authorization: Bearer $JWT" \
72-
-H "Accept: application/vnd.github.v3+json" \
73-
https://api.github.com/app/installations | jq -r '.[0].id')
74-
75-
# Request Installation Access Token
76-
ACCESS_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $JWT" \
77-
-H "Accept: application/vnd.github.v3+json" \
78-
"https://api.github.com/app/installations/$INSTALLATION_ID/access_tokens" | jq -r '.token')
79-
80-
echo "ACCESS_TOKEN=$ACCESS_TOKEN" >> "$GITHUB_ENV"
81-
82-
rm -f private-key.pem
83-
8438
- name: Checkout repository
8539
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8640
with:
87-
repository: ${{ github.event.pull_request.head.repo.full_name }}
88-
ref: ${{ github.event.pull_request.head.ref }}
8941
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
90-
token: ${{ env.ACCESS_TOKEN }}
9142

9243
- name: Set up Node.js
9344
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
@@ -145,21 +96,26 @@ jobs:
14596
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
14697
run: git diff
14798

148-
- name: Configure git user name and email
99+
- name: Create directory for PR data
149100
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
150-
run: |
151-
git config user.name "test-wp-build-script-commit[bot]"
152-
git config user.email ${{ env.GH_APP_ID }}+test-wp-build-script-commit[bot]@users.noreply.github.com
101+
run: mkdir -p ./pr-data
153102

154-
- name: Stage changes
103+
- name: Save diff to a file
155104
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
156-
run: git add .
105+
run: git diff > ./pr-data/changes.diff
157106

158-
- name: Commit changes
107+
- name: Save PR number
159108
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
160109
run: |
161-
git commit -m "Automation: Updating built files with changes. [dependabot skip]"
110+
echo "${EVENT_NUMBER}" > ./pr-data/NR
111+
env:
112+
EVENT_NUMBER: ${{ github.event.number }}
162113

163-
- name: Push changes
114+
# Uploads the PR number and diff as an artifact for the Commit Built File Changes workflow to download and then
115+
# commit back for testing.
116+
- name: Upload PR data as artifact
117+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
164118
if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }}
165-
run: git push
119+
with:
120+
name: pr-data
121+
path: pr-data/

0 commit comments

Comments
 (0)