|
1 |
| -name: Trigger dependency update in Upgrader |
| 1 | +name: Update Spryker Upgrader |
2 | 2 |
|
3 | 3 | env:
|
4 |
| - AUTH_TOKEN: ${{ secrets.PAT }} |
5 |
| - EVENT: integrator_dependency_updated |
6 |
| - ORG: spryker-sdk |
7 |
| - REPO: upgrader |
| 4 | + TARGET_BRANCH: master |
| 5 | + TARGET_OWNER: spryker-sdk |
| 6 | + TARGET_REPO: upgrader |
| 7 | + SOURCE_PACKAGE_NAME: 'spryker-sdk/integrator' |
| 8 | + PR_LABELS: 'composer dependencies' |
| 9 | + PR_ASSIGNEES: pavelmaksimov25,DmytroKlymanSpryker |
8 | 10 |
|
9 | 11 | on:
|
10 |
| - push: |
11 |
| - branches: |
12 |
| - - master |
| 12 | + pull_request: |
| 13 | + types: [closed] |
| 14 | + workflow_dispatch: |
13 | 15 |
|
14 | 16 | jobs:
|
15 |
| - trigger-external-pr: |
16 |
| - runs-on: ubuntu-latest |
17 |
| - steps: |
18 |
| - - name: Trigger external repository pr creation |
19 |
| - run: | |
20 |
| - curl -d "{\"event_type\": \"${EVENT}\"}" \ |
21 |
| - -X POST \ |
22 |
| - -H "Content-Type: application/json" \ |
23 |
| - -H "Authorization: token ${AUTH_TOKEN}" \ |
24 |
| - -H "Accept: application/vnd.github.everest-preview+json" \ |
25 |
| - "https://api.github.com/repos/${ORG}/${REPO}/dispatches" |
| 17 | + trigger-external-pr: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + if: ${{ github.event.pull_request.merged == true }} |
| 20 | + |
| 21 | + steps: |
| 22 | + # https://github.com/marketplace/actions/setup-php-action |
| 23 | + - name: "Install PHP" |
| 24 | + uses: shivammathur/setup-php@2.27.0 |
| 25 | + with: |
| 26 | + php-version: 8.0 |
| 27 | + tools: composer:v2 |
| 28 | + |
| 29 | + - run: | |
| 30 | + echo ${{ github.event.pull_request.merged }} |
| 31 | + echo ${{ github.event.pull_request }} |
| 32 | +
|
| 33 | + # https://github.com/marketplace/actions/get-current-pull-request |
| 34 | + - name: "Collect PR data" |
| 35 | + uses: 8BitJonny/gh-get-current-pr@2.2.0 |
| 36 | + id: PR |
| 37 | + with: |
| 38 | + github-token: ${{ secrets.PAT }} |
| 39 | + sha: ${{ github.event.pull_request.head.sha }} |
| 40 | + |
| 41 | + # https://github.com/marketplace/actions/checkout |
| 42 | + - name: "Checkout target repository" |
| 43 | + if: ${{ success() }} |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + token: ${{ secrets.PAT }} |
| 47 | + repository: ${{ env.TARGET_OWNER }}/${{ env.TARGET_REPO }} |
| 48 | + path: ${{ env.TARGET_REPO }} |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: "Update composer dependency" |
| 52 | + if: ${{ success() }} |
| 53 | + run: | |
| 54 | + composer update ${{ env.SOURCE_PACKAGE_NAME }} --no-scripts --no-progress --no-install |
| 55 | + working-directory: ${{ env.TARGET_REPO }} |
| 56 | + |
| 57 | + - name: "Prepare PR Body" |
| 58 | + if: ${{ success() }} |
| 59 | + id: target-pr-body |
| 60 | + run: | |
| 61 | + target_pr_body="This PR is automatically created by GitHub action to update dependency. |
| 62 | + Original PR [${{ steps.PR.outputs.number }}](${{ steps.PR.outputs.pr_url }}) |
| 63 | + Original PR Body: |
| 64 | + ${{ steps.PR.outputs.pr_body }}" |
| 65 | +
|
| 66 | + echo 'target_pr_body<<EOF' >> $GITHUB_OUTPUT |
| 67 | + echo "$target_pr_body" >> $GITHUB_OUTPUT |
| 68 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 69 | +
|
| 70 | + # https://github.com/marketplace/actions/create-pull-request |
| 71 | + - name: "Commit, push and create pull request." |
| 72 | + if: ${{ success() }} |
| 73 | + uses: peter-evans/create-pull-request@v5 |
| 74 | + with: |
| 75 | + token: ${{ secrets.PAT }} |
| 76 | + path: ${{ env.TARGET_REPO }} |
| 77 | + base: ${{ env.TARGET_BRANCH }} |
| 78 | + branch: ${{ format('{0}-dependency-{1}-{2}', fromJson(steps.PR.outputs.pr).head.ref, env.REPO, steps.PR.outputs.number) }} |
| 79 | + branch-suffix: timestamp |
| 80 | + title: ${{ format('Dependency update. {0}', steps.PR.outputs.pr_title) }} |
| 81 | + body: ${{ steps.target-pr-body.outputs.target_pr_body }} |
| 82 | + committer: SprykerReleaseBot <spryker-release-bot@spryker.com> |
| 83 | + author: SprykerReleaseBot <spryker-release-bot@spryker.com> |
| 84 | + labels: ${{ env.PR_LABELS }} |
| 85 | + delete-branch: true |
| 86 | + assignees: ${{ env.PR_ASSIGNEES }} |
0 commit comments