Skip to content

Commit eaa6503

Browse files
Merge pull request #363 from nextcloud/ci/update-workflows
ci: Update workflows
2 parents c5365e2 + 60930d0 commit eaa6503

5 files changed

Lines changed: 97 additions & 67 deletions

File tree

.github/workflows/dependabot-approve-merge.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ concurrency:
2424

2525
jobs:
2626
auto-approve-merge:
27-
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]'
27+
if: github.event.pull_request.user.login == 'dependabot[bot]'
2828
runs-on: ubuntu-latest-low
29+
env:
30+
# env variable for maintainers: 'true' allows to auto-merge 1.0.2 -> 2.0.0
31+
ALLOW_MAJOR: false
32+
# env variable for maintainers: 'true' allows to auto-merge 1.0.2 -> 1.1.0
33+
ALLOW_MINOR: true
34+
# env variable for maintainers: RegExp string to ignore some dependencies from auto-approve and auto-merge
35+
IGNORE_PATTERN: ''
2936
permissions:
30-
# for hmarr/auto-approve-action to approve PRs
37+
# for auto-approve step to work
3138
pull-requests: write
3239
# for alexwilson/enable-github-automerge-action to approve PRs
3340
contents: write
@@ -44,15 +51,51 @@ jobs:
4451
with:
4552
repo-token: ${{ secrets.GITHUB_TOKEN }}
4653

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
54+
- name: Dependabot metadata
55+
id: metadata
56+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
57+
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
5058
with:
5159
github-token: ${{ secrets.GITHUB_TOKEN }}
5260

61+
- name: Check for ignored dependencies in the PR
62+
id: validate
63+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
64+
env:
65+
IGNORE_PATTERN: ${{ env.IGNORE_PATTERN }}
66+
DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }}
67+
run: |
68+
if [[ -z ${IGNORE_PATTERN} ]]; then
69+
echo "ignore=false" >> "$GITHUB_OUTPUT"
70+
elif [[ -z ${DEPENDENCY_NAMES} ]]; then
71+
echo "ignore=false" >> "$GITHUB_OUTPUT"
72+
elif [[ ${DEPENDENCY_NAMES} =~ ${IGNORE_PATTERN} ]]; then
73+
echo "ignore=true" >> "$GITHUB_OUTPUT"
74+
fi
75+
76+
- name: GitHub actions bot approve
77+
id: auto_approve
78+
if: ${{
79+
startsWith(steps.branchname.outputs.branch, 'dependabot/')
80+
&& steps.validate.outputs.ignore != 'true'
81+
}}
82+
run: gh pr review --approve "$PR_URL"
83+
env:
84+
PR_URL: ${{ github.event.pull_request.html_url }}
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
5387
# Enable GitHub auto merge
5488
- name: Auto merge
55-
uses: alexwilson/enable-github-automerge-action@2c32e18a76e0726ffe7a573bfff2d42a20885126 # v3.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
89+
uses: alexwilson/enable-github-automerge-action@2c32e18a76e0726ffe7a573bfff2d42a20885126 # 3.0.0
90+
if: ${{
91+
startsWith(steps.branchname.outputs.branch, 'dependabot/')
92+
&& steps.auto_approve.conclusion == 'success'
93+
&& (github.event.action == 'opened' || github.event.action == 'reopened')
94+
&& (
95+
steps.metadata.outputs.update-type == 'version-update:semver-patch'
96+
|| (fromJSON(env.ALLOW_MINOR) && steps.metadata.outputs.update-type == 'version-update:semver-minor')
97+
|| (fromJSON(env.ALLOW_MAJOR) && steps.metadata.outputs.update-type == 'version-update:semver-major')
98+
)
99+
}}
57100
with:
58101
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint-php-cs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
persist-credentials: false
3131

3232
- name: Set up php8.3
33-
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
33+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
3434
with:
3535
php-version: 8.3
3636
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite

.github/workflows/lint-php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ concurrency:
1919

2020
jobs:
2121
php-lint:
22-
runs-on: ubuntu-latest
22+
runs-on: ubuntu-latest-low
2323
strategy:
2424
matrix:
2525
php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
@@ -33,7 +33,7 @@ jobs:
3333
persist-credentials: false
3434

3535
- name: Set up php ${{ matrix.php-versions }}
36-
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
36+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
3737
with:
3838
php-version: ${{ matrix.php-versions }}
3939
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite

.github/workflows/update-nextcloud-ocp-approve-merge.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
if: github.actor == 'nextcloud-command'
2828
runs-on: ubuntu-latest-low
2929
permissions:
30-
# for hmarr/auto-approve-action to approve PRs
30+
# for auto-approve-action to approve PRs
3131
pull-requests: write
3232
# for alexwilson/enable-github-automerge-action to approve PRs
3333
contents: write
@@ -44,15 +44,16 @@ jobs:
4444
with:
4545
repo-token: ${{ secrets.GITHUB_TOKEN }}
4646

47-
# GitHub actions bot approve
48-
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
47+
- name: GitHub actions bot approve
4948
if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
50-
with:
51-
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
run: gh pr review --approve "$PR_URL"
50+
env:
51+
PR_URL: ${{ github.event.pull_request.html_url }}
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5253

5354
# Enable GitHub auto merge
5455
- name: Auto merge
55-
uses: alexwilson/enable-github-automerge-action@2c32e18a76e0726ffe7a573bfff2d42a20885126 # v3.0.0
56+
uses: alexwilson/enable-github-automerge-action@2c32e18a76e0726ffe7a573bfff2d42a20885126 # 3.0.0
5657
if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
5758
with:
5859
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/update-nextcloud-ocp.yml

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,25 @@ jobs:
2121
update-nextcloud-ocp:
2222
runs-on: ubuntu-latest
2323

24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
branches:
28-
- ${{ github.event.repository.default_branch }}
29-
- 'stable32'
30-
- 'stable31'
24+
# Only allowed to be run on nextcloud repositories
25+
if: ${{ github.repository_owner == 'nextcloud' }}
3126

32-
name: update-nextcloud-ocp-${{ matrix.branches }}
27+
name: update-nextcloud-ocp-main
3328

3429
steps:
3530
- id: checkout
3631
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
3732
with:
3833
persist-credentials: false
39-
ref: ${{ matrix.branches }}
34+
ref: main
4035
submodules: true
4136
continue-on-error: true
4237

43-
- name: Set up php8.2
38+
- name: Set up php8.3
4439
if: steps.checkout.outcome == 'success'
45-
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
40+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
4641
with:
47-
php-version: 8.2
42+
php-version: 8.3
4843
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
4944
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
5045
coverage: none
@@ -62,53 +57,39 @@ jobs:
6257
if: steps.checkout.outcome == 'success'
6358
run: composer install
6459

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' }}
60+
- name: Check composer bin for nextcloud/ocp exists
61+
id: check_composer_bin
62+
uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
7363
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 }}'
64+
files: vendor-bin/nextcloud-ocp/composer.json
7765

7866
- 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
67+
id: update_branch
68+
env:
69+
USE_COMPOSER_BIN: ${{ steps.check_composer_bin.outputs.files_exists }}
70+
BRANCH_NAME: main
71+
run: |
72+
COMPOSER_CMD='composer'
73+
if [[ "$USE_COMPOSER_BIN" == 'true' ]]; then
74+
COMPOSER_CMD='composer bin nextcloud-ocp'
75+
fi
76+
77+
PACKAGE_VERSION="nextcloud/ocp:dev-$BRANCH_NAME"
78+
if [[ "$BRANCH_NAME" == 'main' ]]; then
79+
PACKAGE_VERSION='nextcloud/ocp:dev-master'
80+
fi
81+
82+
echo $COMPOSER_CMD require --dev $PACKAGE_VERSION
83+
$COMPOSER_CMD require --dev $PACKAGE_VERSION
8284
8385
- name: Raise on issue on failure
8486
uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
85-
if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_main.conclusion == 'failure' }}
87+
if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_branch.conclusion == 'failure' }}
8688
with:
8789
token: ${{ secrets.GITHUB_TOKEN }}
88-
title: 'Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}'
90+
title: 'Failed to update nextcloud/ocp package on branch main'
8991
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 }}'
9092

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-
11293
- name: Create Pull Request
11394
if: steps.checkout.outcome == 'success'
11495
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
@@ -118,8 +99,13 @@ jobs:
11899
committer: GitHub <noreply@github.com>
119100
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
120101
signoff: true
121-
branch: 'automated/noid/${{ matrix.branches }}-update-nextcloud-ocp'
122-
title: '[${{ matrix.branches }}] Update nextcloud/ocp dependency'
102+
branch: 'automated/noid/main-update-nextcloud-ocp'
103+
title: '[main] Update nextcloud/ocp dependency'
104+
add-path: |
105+
composer.json
106+
composer.lock
107+
vendor-bin/nextcloud-ocp/composer.json
108+
vendor-bin/nextcloud-ocp/composer.lock
123109
body: |
124110
Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency
125111
labels: |

0 commit comments

Comments
 (0)