|
1 | | -name: Update Buildpack Dependency |
| 1 | +name: Update buildpack.toml |
2 | 2 |
|
3 | 3 | on: |
4 | | - repository_dispatch: |
5 | | - types: dependency-update |
| 4 | + schedule: |
| 5 | + - cron: '*/15 * * * *' |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
6 | 9 |
|
7 | 10 | jobs: |
8 | 11 | update-buildpack-toml: |
9 | 12 | runs-on: ubuntu-latest |
10 | 13 | name: Update buildpack.toml |
11 | 14 | steps: |
12 | 15 |
|
13 | | - - name: Parse ID and Version |
14 | | - id: dependency |
15 | | - run: | |
16 | | - echo "::set-output name=id::$(jq -r .client_payload.dependency.id ${{ github.event_path }})" |
17 | | - echo "::set-output name=version::$(jq -r .client_payload.dependency.version ${{ github.event_path }})" |
18 | | -
|
19 | 16 | - name: Checkout |
20 | 17 | uses: actions/checkout@v2 |
21 | 18 |
|
22 | 19 | - name: Checkout Branch |
23 | | - run: | |
24 | | - branch="automation/dependency-update/${{ steps.dependency.outputs.id }}" |
25 | | - git fetch origin |
26 | | - if git branch -a | grep "${branch}"; then |
27 | | - git checkout -b "${branch}" "origin/${branch}" |
28 | | - git pull -r |
29 | | - else |
30 | | - git checkout -b "${branch}" |
31 | | - fi |
| 20 | + uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main |
| 21 | + with: |
| 22 | + branch: automation/buildpack.toml/update |
32 | 23 |
|
33 | 24 | - name: Update buildpack.toml |
34 | | - uses: paketo-buildpacks/github-config/actions/dependency/update@main |
| 25 | + uses: paketo-buildpacks/github-config/actions/buildpack/update@main |
35 | 26 |
|
36 | 27 | - name: Commit |
37 | | - run: | |
38 | | - git config --global user.email "[email protected]" |
39 | | - git config --global user.name "paketo-bot" |
40 | | - git commit \ |
41 | | - --all \ |
42 | | - --message "Updating ${{ steps.dependency.outputs.id }} to ${{ steps.dependency.outputs.version }} in buildpack.toml" |
| 28 | + uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main |
| 29 | + with: |
| 30 | + message: "Updating buildpacks in buildpack.toml" |
| 31 | + pathspec: "." |
43 | 32 |
|
44 | 33 | - name: Push Branch |
45 | | - run: | |
46 | | - git remote add origin-ssh "[email protected]:${{ github.repository }}.git" |
47 | | - eval "$(ssh-agent)" |
48 | | - echo "${{ secrets.PAKETO_BOT_SSH_KEY }}" | ssh-add - |
49 | | - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git \ |
50 | | - push origin "automation/dependency-update/${{ steps.dependency.outputs.id }}" |
| 34 | + uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main |
| 35 | + with: |
| 36 | + branch: automation/buildpack.toml/update |
51 | 37 |
|
52 | 38 | - name: Open Pull Request |
53 | | - run: | |
54 | | - branch="automation/dependency-update/${{ steps.dependency.outputs.id }}" |
55 | | - org="$(echo "${GITHUB_REPOSITORY}" | cut -d'/' -f1)" |
56 | | - count="$( |
57 | | - curl "https://api.github.com/repos/${{ github.repository }}/pulls?head=${org}:${branch}" \ |
58 | | - -H "Authorization: token ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}" \ |
59 | | - --silent \ |
60 | | - | jq -r 'length' |
61 | | - )" |
62 | | -
|
63 | | - if [[ "${count}" != "0" ]]; then |
64 | | - echo "PR already exists, updated with new commit." |
65 | | - exit 0 |
66 | | - fi |
67 | | -
|
68 | | - curl "https://api.github.com/repos/${{ github.repository }}/pulls" \ |
69 | | - -H "Authorization: token ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}" \ |
70 | | - -X POST \ |
71 | | - --data '{ |
72 | | - "head": "automation/dependency-update/${{ steps.dependency.outputs.id }}", |
73 | | - "base": "main", |
74 | | - "title": "Updates ${{ steps.dependency.outputs.id }}" |
75 | | - }' |
76 | | -
|
| 39 | + uses: paketo-buildpacks/github-config/actions/pull-request/open@main |
| 40 | + with: |
| 41 | + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} |
| 42 | + title: "Updates buildpacks in buildpack.toml" |
| 43 | + branch: automation/buildpack.toml/update |
0 commit comments