Changeset 60063
- Timestamp:
- 03/21/2025 04:33:17 PM (4 months ago)
- Location:
- trunk/.github/workflows
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/check-built-files.yml
r59984 r60063 1 # Checks for uncommitted changes to built files and pushes changes back.2 name: Check built files1 # Checks for uncommitted changes to built files in pull requests. 2 name: Check Built Files (PRs) 3 3 4 4 on: … … 6 6 # runs for pull requests. 7 7 # 8 # Other workflows that run on pushwill detect changes to versioned files and fail.9 pull_request _target:8 # Other workflows that run for the push event will detect changes to versioned files and fail. 9 pull_request: 10 10 branches: 11 11 - trunk … … 32 32 # The concurrency group contains the workflow name and the branch name for pull requests 33 33 # 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 }} 35 35 cancel-in-progress: true 36 36 … … 40 40 41 41 jobs: 42 update-built-files: 43 name: Update built files 44 permissions: 45 contents: write 46 if: ${{ github.repository == 'WordPress/wordpress-develop' }} 47 # This should always reference a version of the workflow committed through SVN and never a local reference. 48 uses: WordPress/wordpress-develop/.github/workflows/reusable-check-built-files.yml@trunk 49 secrets: 50 GH_APP_ID: ${{ secrets.GH_PR_MANAGEMENT_APP_ID }} 51 GH_APP_PRIVATE_KEY: ${{ secrets.GH_PR_MANAGEMENT_APP_PRIVATE_KEY }} 42 check-for-built-file-changes: 43 name: Check built files 44 # This prevents an unnecessary second run after changes are committed back because Dependabot always rebases and force pushes. 45 if: ${{ github.repository == 'wordpress/wordpress-develop' && ( github.actor != 'dependabot[bot]' || github.event.commits < 2 ) }} 46 uses: ./.github/workflows/reusable-check-built-files.yml -
trunk/.github/workflows/reusable-check-built-files.yml
r60059 r60063 1 name: Lint GitHub Actions workflows 1 ## 2 # A reusable workflow that checks for uncommitted changes to built files in pull requests. 3 ## 4 name: Check Built Files (PRs) 5 2 6 on: 3 7 workflow_call: 4 secrets:5 GH_APP_ID:6 description: 'A GitHub App ID.'7 required: true8 GH_APP_PRIVATE_KEY:9 description: 'A GitHub App private key.'10 required: true11 8 12 9 permissions: {} … … 15 12 # Checks a PR for uncommitted changes to built files. 16 13 # 17 # This job uses a GitHub App instead of $GITHUB_TOKEN because Dependabot pull requests are only granted18 # read-only access.14 # When changes are detected, the patch is stored as an artifact for processing by the Commit Built File Changes 15 # workflow. 19 16 # 20 17 # Performs the following steps: 21 # - Generates a token for authenticating with the GitHub App.22 18 # - Checks out the repository. 23 19 # - Sets up Node.js. … … 32 28 # - Checks for changes to versioned files. 33 29 # - Displays the result of git diff for debugging purposes. 34 # - Configures the Git author. 35 # - Stages changes. 36 # - Commits changes. 37 # - Pushes changes. 30 # - Saves the diff to a patch file. 31 # - Uploads the patch file as an artifact. 38 32 update-built-files: 39 33 name: Check and update built files 40 34 runs-on: ubuntu-24.04 41 # This prevents an unnecessary second run after changes are committed back because Dependabot always rebases42 # updates and force pushes.43 if: ${{ github.actor != 'dependabot[bot]' || github.event.commits < 2 }}44 35 timeout-minutes: 10 45 permissions:46 contents: write47 36 steps: 48 - name: Generate Installation Token49 id: generate_token50 env:51 GH_APP_ID: ${{ secrets.GH_APP_ID }}52 GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}53 run: |54 echo "$GH_APP_PRIVATE_KEY" > private-key.pem55 56 # Generate JWT57 JWT=$(python3 - <<EOF58 import jwt, time59 private_key = open("private-key.pem", "r").read()60 payload = {61 "iat": int(time.time()),62 "exp": int(time.time()) + 600, # 10-minute expiration63 "iss": $GH_APP_ID64 }65 print(jwt.encode(payload, private_key, algorithm="RS256"))66 EOF67 )68 69 # Get Installation ID70 INSTALLATION_ID=$(curl -s -X GET -H "Authorization: Bearer $JWT" \71 -H "Accept: application/vnd.github.v3+json" \72 https://api.github.com/app/installations | jq -r '.[0].id')73 74 # Request Installation Access Token75 ACCESS_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $JWT" \76 -H "Accept: application/vnd.github.v3+json" \77 "https://api.github.com/app/installations/$INSTALLATION_ID/access_tokens" | jq -r '.token')78 79 echo "ACCESS_TOKEN=$ACCESS_TOKEN" >> "$GITHUB_ENV"80 81 rm -f private-key.pem82 83 37 - name: Checkout repository 84 38 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 85 39 with: 86 repository: ${{ github.event.pull_request.head.repo.full_name }}87 ref: ${{ github.event.pull_request.head.ref }}88 40 show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} 89 token: ${{ env.ACCESS_TOKEN }}90 41 91 42 - name: Set up Node.js … … 145 96 run: git diff 146 97 147 - name: Configure git user name and email98 - name: Save diff to a file 148 99 if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} 149 run: | 150 git config user.name "wordpress-develop-pr-bot[bot]" 151 git config user.email ${{ secrets.GH_APP_ID }}+wordpress-develop-pr-bot[bot]@users.noreply.github.com 100 run: git diff > ./changes.diff 152 101 153 - name: Stage changes 102 # Uploads the diff file as an artifact. 103 - name: Upload diff file as artifact 104 uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 154 105 if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} 155 run: git add . 156 157 - name: Commit changes 158 if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} 159 run: | 160 git commit -m "Automation: Updating built files with changes. [dependabot skip]" 161 162 - name: Push changes 163 if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} 164 run: git push 106 with: 107 name: pr-built-file-changes 108 path: changes.diff
Note: See TracChangeset
for help on using the changeset viewer.