|
| 1 | +name: Update Dependencies |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Weekly on Sunday at 03:00 UTC |
| 6 | + - cron: '0 3 * * 0' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-and-verify: |
| 15 | + name: Update Dependencies & Verify QA |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + ref: php8.4 |
| 23 | + |
| 24 | + - name: Setup PHP |
| 25 | + uses: shivammathur/setup-php@v2 |
| 26 | + with: |
| 27 | + php-version: '8.4' |
| 28 | + tools: composer:v2, phive |
| 29 | + coverage: xdebug |
| 30 | + extensions: json, tokenizer, mbstring |
| 31 | + |
| 32 | + - name: Get composer cache directory |
| 33 | + id: composer-cache |
| 34 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 35 | + |
| 36 | + - name: Cache composer dependencies |
| 37 | + uses: actions/cache@v4 |
| 38 | + with: |
| 39 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 40 | + key: ${{ runner.os }}-composer-update-${{ hashFiles('**/composer.lock') }} |
| 41 | + restore-keys: | |
| 42 | + ${{ runner.os }}-composer-update- |
| 43 | + ${{ runner.os }}-composer- |
| 44 | +
|
| 45 | + # Step 1: Update composer dependencies |
| 46 | + - name: Update composer dependencies |
| 47 | + run: composer update --no-interaction --no-progress --prefer-dist |
| 48 | + |
| 49 | + # Step 2: Update PHARs via phive |
| 50 | + - name: Import GPG keys for PHAR verification |
| 51 | + run: | |
| 52 | + gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys \ |
| 53 | + C6D76C329EBADE2FB9C458CFC5095986493B4AA0 \ |
| 54 | + 033E5F8D801A2F8D || true |
| 55 | + gpg --batch --keyserver hkps://keyserver.ubuntu.com --recv-keys \ |
| 56 | + 51C67305FFC2E5C0 \ |
| 57 | + E82B2FB314E9906E || true |
| 58 | +
|
| 59 | + - name: Update PHARs via phive |
| 60 | + run: | |
| 61 | + phive update --copy \ |
| 62 | + --trust-gpg-keys C6D76C329EBADE2FB9C458CFC5095986493B4AA0,51C67305FFC2E5C0,E82B2FB314E9906E,033E5F8D801A2F8D \ |
| 63 | + || echo "::warning::phive update failed (GPG key server issue?) - continuing with existing PHARs" |
| 64 | +
|
| 65 | + # Step 3: Update isolated Rector |
| 66 | + - name: Update isolated Rector |
| 67 | + run: composer update --working-dir=tools/rector --no-interaction --no-dev |
| 68 | + |
| 69 | + # Step 4: Check for changes |
| 70 | + - name: Detect changes |
| 71 | + id: changes |
| 72 | + run: | |
| 73 | + if git diff --quiet; then |
| 74 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 75 | + echo "No dependency changes detected" |
| 76 | + else |
| 77 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 78 | + echo "Changes detected:" |
| 79 | + git diff --stat |
| 80 | + fi |
| 81 | +
|
| 82 | + # Step 5: Run full QA pipeline (only if changes detected) |
| 83 | + - name: Run QA Pipeline |
| 84 | + if: steps.changes.outputs.changed == 'true' |
| 85 | + env: |
| 86 | + CI: true |
| 87 | + skipUncommittedChangesCheck: 1 |
| 88 | + phpUnitQuickTests: 0 |
| 89 | + phpUnitCoverage: 0 |
| 90 | + run: bash ci.bash |
| 91 | + |
| 92 | + # Step 6: Generate PR summary |
| 93 | + - name: Generate update summary |
| 94 | + if: steps.changes.outputs.changed == 'true' |
| 95 | + id: summary |
| 96 | + run: | |
| 97 | + echo "body<<EOF" >> "$GITHUB_OUTPUT" |
| 98 | + echo "## Composer Changes" >> "$GITHUB_OUTPUT" |
| 99 | + echo "" >> "$GITHUB_OUTPUT" |
| 100 | + echo '```diff' >> "$GITHUB_OUTPUT" |
| 101 | + git diff composer.lock | head -100 >> "$GITHUB_OUTPUT" |
| 102 | + echo '```' >> "$GITHUB_OUTPUT" |
| 103 | + echo "" >> "$GITHUB_OUTPUT" |
| 104 | +
|
| 105 | + # Check for PHAR changes |
| 106 | + if ! git diff --quiet phive.xml vendor-phar/; then |
| 107 | + echo "## PHAR Changes" >> "$GITHUB_OUTPUT" |
| 108 | + echo "" >> "$GITHUB_OUTPUT" |
| 109 | + for phar in vendor-phar/*.phar; do |
| 110 | + name=$(basename "$phar" .phar) |
| 111 | + echo "- **$name**: $(php "$phar" --version 2>/dev/null | head -1 || echo 'version unknown')" >> "$GITHUB_OUTPUT" |
| 112 | + done |
| 113 | + echo "" >> "$GITHUB_OUTPUT" |
| 114 | + fi |
| 115 | +
|
| 116 | + # Check for Rector changes |
| 117 | + if ! git diff --quiet tools/rector/composer.lock; then |
| 118 | + echo "## Rector Changes" >> "$GITHUB_OUTPUT" |
| 119 | + echo "" >> "$GITHUB_OUTPUT" |
| 120 | + echo '```diff' >> "$GITHUB_OUTPUT" |
| 121 | + git diff tools/rector/composer.lock | head -50 >> "$GITHUB_OUTPUT" |
| 122 | + echo '```' >> "$GITHUB_OUTPUT" |
| 123 | + fi |
| 124 | +
|
| 125 | + echo "" >> "$GITHUB_OUTPUT" |
| 126 | + echo "---" >> "$GITHUB_OUTPUT" |
| 127 | + echo "QA pipeline passed with these changes." >> "$GITHUB_OUTPUT" |
| 128 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 129 | +
|
| 130 | + # Step 7: Create PR (only if QA passed — this step is skipped if ci.bash failed) |
| 131 | + - name: Create Pull Request |
| 132 | + if: steps.changes.outputs.changed == 'true' |
| 133 | + id: create-pr |
| 134 | + uses: peter-evans/create-pull-request@v8 |
| 135 | + with: |
| 136 | + branch: chore/update-deps |
| 137 | + delete-branch: true |
| 138 | + title: 'chore(deps): update dependencies' |
| 139 | + body: | |
| 140 | + Automated weekly dependency update. |
| 141 | +
|
| 142 | + ${{ steps.summary.outputs.body }} |
| 143 | +
|
| 144 | + This PR was created automatically by the [update-deps](${{ github.server_url }}/${{ github.repository }}/actions/workflows/update-deps.yml) workflow. |
| 145 | + labels: dependencies,automated |
| 146 | + commit-message: 'chore(deps): update all dependencies' |
| 147 | + |
| 148 | + - name: Enable auto-merge |
| 149 | + if: steps.create-pr.outputs.pull-request-number |
| 150 | + run: gh pr merge --auto --squash "${{ steps.create-pr.outputs.pull-request-number }}" |
| 151 | + env: |
| 152 | + GH_TOKEN: ${{ github.token }} |
0 commit comments