Skip to content

Commit 2969dbb

Browse files
committed
ci(actions): Update OCP and automerge it
Signed-off-by: Joas Schilling <[email protected]>
1 parent 963e756 commit 2969dbb

File tree

3 files changed

+243
-0
lines changed

3 files changed

+243
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Auto approve Dependabot PRs
10+
11+
on:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
13+
branches:
14+
- main
15+
- master
16+
- stable*
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: dependabot-approve-merge-${{ github.head_ref || github.run_id }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
auto-approve-merge:
27+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]'
28+
runs-on: ubuntu-latest-low
29+
permissions:
30+
# for hmarr/auto-approve-action to approve PRs
31+
pull-requests: write
32+
# for alexwilson/enable-github-automerge-action to approve PRs
33+
contents: write
34+
35+
steps:
36+
- name: Disabled on forks
37+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
38+
run: |
39+
echo 'Can not approve PRs from forks'
40+
exit 1
41+
42+
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43+
id: branchname
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# GitHub actions bot approve
48+
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
49+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/') && contains(steps.branchname.outputs.branch, '/webrtc-adapter-') != true && contains(steps.branchname.outputs.branch, '/nextcloud/vue-') != true
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# Enable GitHub auto merge
54+
- name: Auto merge
55+
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
56+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/') && contains(steps.branchname.outputs.branch, '/webrtc-adapter-') != true && contains(steps.branchname.outputs.branch, '/nextcloud/vue-') != true
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Auto approve nextcloud/ocp
10+
11+
on:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
13+
branches:
14+
- main
15+
- master
16+
- stable*
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: update-nextcloud-ocp-approve-merge-${{ github.head_ref || github.run_id }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
auto-approve-merge:
27+
if: github.actor == 'nextcloud-command'
28+
runs-on: ubuntu-latest-low
29+
permissions:
30+
# for hmarr/auto-approve-action to approve PRs
31+
pull-requests: write
32+
# for alexwilson/enable-github-automerge-action to approve PRs
33+
contents: write
34+
35+
steps:
36+
- name: Disabled on forks
37+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
38+
run: |
39+
echo 'Can not approve PRs from forks'
40+
exit 1
41+
42+
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43+
id: branchname
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# GitHub actions bot approve
48+
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
49+
if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# Enable GitHub auto merge
54+
- name: Auto merge
55+
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
56+
if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Update nextcloud/ocp
10+
11+
on:
12+
workflow_dispatch:
13+
schedule:
14+
- cron: "5 2 * * 0"
15+
16+
permissions:
17+
contents: read
18+
issues: write
19+
20+
jobs:
21+
update-nextcloud-ocp:
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
branches:
28+
- ${{ github.event.repository.default_branch }}
29+
- 'stable32'
30+
- 'stable31'
31+
32+
name: update-nextcloud-ocp-${{ matrix.branches }}
33+
34+
steps:
35+
- id: checkout
36+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
37+
with:
38+
persist-credentials: false
39+
ref: ${{ matrix.branches }}
40+
submodules: true
41+
continue-on-error: true
42+
43+
- name: Set up php8.2
44+
if: steps.checkout.outcome == 'success'
45+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5
46+
with:
47+
php-version: 8.2
48+
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
49+
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
50+
coverage: none
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Read codeowners
55+
if: steps.checkout.outcome == 'success'
56+
id: codeowners
57+
run: |
58+
grep '/appinfo/info.xml' .github/CODEOWNERS | cut -f 2- -d ' ' | xargs | awk '{ print "codeowners="$0 }' >> $GITHUB_OUTPUT
59+
continue-on-error: true
60+
61+
- name: Composer install
62+
if: steps.checkout.outcome == 'success'
63+
run: composer install
64+
65+
- name: Composer update nextcloud/ocp # zizmor: ignore[template-injection]
66+
id: update_branch
67+
if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }}
68+
run: composer require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
69+
70+
- name: Raise on issue on failure
71+
uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
72+
if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_branch.conclusion == 'failure' }}
73+
with:
74+
token: ${{ secrets.GITHUB_TOKEN }}
75+
title: 'Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}'
76+
body: 'Please check the output of the GitHub action and manually resolve the issues<br>${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}<br>${{ steps.codeowners.outputs.codeowners }}'
77+
78+
- name: Composer update nextcloud/ocp
79+
id: update_main
80+
if: ${{ steps.checkout.outcome == 'success' && matrix.branches == 'main' }}
81+
run: composer require --dev nextcloud/ocp:dev-master
82+
83+
- name: Raise on issue on failure
84+
uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
85+
if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_main.conclusion == 'failure' }}
86+
with:
87+
token: ${{ secrets.GITHUB_TOKEN }}
88+
title: 'Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}'
89+
body: 'Please check the output of the GitHub action and manually resolve the issues<br>${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}<br>${{ steps.codeowners.outputs.codeowners }}'
90+
91+
- name: Reset checkout 3rdparty
92+
if: steps.checkout.outcome == 'success'
93+
run: |
94+
git clean -f 3rdparty
95+
git checkout 3rdparty
96+
continue-on-error: true
97+
98+
- name: Reset checkout vendor
99+
if: steps.checkout.outcome == 'success'
100+
run: |
101+
git clean -f vendor
102+
git checkout vendor
103+
continue-on-error: true
104+
105+
- name: Reset checkout vendor-bin
106+
if: steps.checkout.outcome == 'success'
107+
run: |
108+
git clean -f vendor-bin
109+
git checkout vendor-bin
110+
continue-on-error: true
111+
112+
- name: Create Pull Request
113+
if: steps.checkout.outcome == 'success'
114+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
115+
with:
116+
token: ${{ secrets.COMMAND_BOT_PAT }}
117+
commit-message: 'chore(dev-deps): Bump nextcloud/ocp package'
118+
committer: GitHub <[email protected]>
119+
author: nextcloud-command <[email protected]>
120+
signoff: true
121+
branch: 'automated/noid/${{ matrix.branches }}-update-nextcloud-ocp'
122+
title: '[${{ matrix.branches }}] Update nextcloud/ocp dependency'
123+
body: |
124+
Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency
125+
labels: |
126+
dependencies
127+
3. to review

0 commit comments

Comments
 (0)