-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
97 lines (86 loc) · 2.82 KB
/
composer-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Composer update
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 5"
permissions:
actions: read
checks: none
contents: write
deployments: none
issues: read
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: '5.x-dev'
lfs: false
persist-credentials: false
- name: Install composer dependencies
run: composer install
- name: Prepare branches
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git remote add upstream https://github.com/${GITHUB_REPOSITORY}.git
git push origin --delete composer-update || true
git branch -D composer-update || true
git fetch upstream 5.x-dev
git checkout -f upstream/5.x-dev
git branch composer-update
git checkout -f composer-update
- name: Update composer dependencies
id: update
run: |
composer update --no-ansi 2>&1 | tee COMPOSER_LOG
sed -i -e '1i```\' COMPOSER_LOG
sed -i -e '1icomposer update log:\' COMPOSER_LOG
echo '```' &>> COMPOSER_LOG
changes=( $(git diff composer.lock) )
git add "composer.lock"
# abort here if no change available
if [[ ${#changes[@]} -eq 0 ]]
then
exit 0
fi
echo "message=$(cat COMPOSER_LOG | jq -aRs)" >> $GITHUB_OUTPUT
shell: bash
- name: Push changes
run: |
git commit -m "updates composer dependencies"
git push --set-upstream origin composer-update
shell: bash
if: steps.update.outputs.message
- name: Create PR
run: |
message=
curl \
--request POST \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title":"[automatic composer updates]",
"body":${{ steps.update.outputs.message }},
"head":"composer-update",
"base":"5.x-dev"
}' \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
shell: bash
if: steps.update.outputs.message