Skip to content

Commit 2f3dc7f

Browse files
Merge pull request #1919 from nextcloud/fix/stable29/update-workflows
[stable29] fix: update workflows
2 parents 6763a5d + 0281b86 commit 2f3dc7f

75 files changed

Lines changed: 744 additions & 312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/block-merge-eol.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#
33
# https://github.com/nextcloud/.github
44
# 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
58

69
name: Block merges for EOL
710

@@ -20,18 +23,27 @@ jobs:
2023

2124
# Only run on stableXX branches
2225
if: startsWith( github.base_ref, 'stable')
23-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-latest-low
2427

2528
steps:
26-
- name: Download updater config
27-
run: curl https://github.com/nextcloud/updater_server/production/config/config.php --output config.php
28-
2929
- name: Set server major version environment
30+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
31+
with:
32+
github-token: ${{secrets.GITHUB_TOKEN}}
33+
script: |
34+
const regex = /^stable(\d+)$/
35+
const baseRef = context.payload.pull_request.base.ref
36+
const match = baseRef.match(regex)
37+
if (match) {
38+
console.log('Setting server_major to ' + match[1]);
39+
core.exportVariable('server_major', match[1]);
40+
console.log('Setting current_month to ' + (new Date()).toISOString().substr(0, 7));
41+
core.exportVariable('current_month', (new Date()).toISOString().substr(0, 7));
42+
}
43+
44+
- name: Checking if server ${{ env.server_major }} is EOL
45+
if: ${{ env.server_major != '' }}
3046
run: |
31-
# retrieve version number from branch reference
32-
server_major=$(echo "${{ github.base_ref }}" | sed -En 's/stable//p')
33-
echo "server_major=$server_major" >> $GITHUB_ENV
34-
35-
- name: Checking if ${{ env.server_major }} is EOL
36-
run: |
37-
php -r 'echo json_encode(require_once "config.php");' | jq --arg version "${{ env.server_major }}" '.stable[$version]["100"].eol // .beta[$version]["100"].eol // "NotEOL"' | grep -q "NotEOL"
47+
curl -s https://github.com/nextcloud-releases/updater_server/production/config/major_versions.json \
48+
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99" | . >= "${{ env.current_month }}"' \
49+
| grep -q true

.github/workflows/block-merge-freeze.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#
33
# https://github.com/nextcloud/.github
44
# 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
58

69
name: Block merges during freezes
710

@@ -22,11 +25,33 @@ jobs:
2225

2326
if: github.event.pull_request.draft == false
2427

25-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-latest-low
2629

2730
steps:
28-
- name: Download version.php from ${{ github.base_ref }}
29-
run: curl https://github.com/nextcloud/server/${{ github.base_ref }}/version.php --output version.php
31+
- name: Register server reference to fallback to master branch
32+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
33+
with:
34+
github-token: ${{secrets.GITHUB_TOKEN}}
35+
script: |
36+
const baseRef = context.payload.pull_request.base.ref
37+
if (baseRef === 'main' || baseRef === 'master') {
38+
core.exportVariable('server_ref', 'master');
39+
console.log('Setting server_ref to master');
40+
} else {
41+
const regex = /^stable(\d+)$/
42+
const match = baseRef.match(regex)
43+
if (match) {
44+
core.exportVariable('server_ref', match[0]);
45+
console.log('Setting server_ref to ' + match[0]);
46+
} else {
47+
console.log('Not based on master/main/stable*, so skipping freeze check');
48+
}
49+
}
50+
51+
- name: Download version.php from ${{ env.server_ref }}
52+
if: ${{ env.server_ref != '' }}
53+
run: curl 'https://github.com/nextcloud/server/${{ env.server_ref }}/version.php' --output version.php
3054

3155
- name: Run check
56+
if: ${{ env.server_ref != '' }}
3257
run: cat version.php | grep 'OC_VersionString' | grep -i -v 'RC'

.github/workflows/command-compile.yml

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
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: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
19
name: Compile Command
210
on:
311
issue_comment:
412
types: [created]
513

14+
permissions:
15+
contents: read
16+
617
jobs:
718
init:
819
runs-on: ubuntu-latest
@@ -18,6 +29,28 @@ jobs:
1829
base_ref: ${{ steps.comment-branch.outputs.base_ref }}
1930

2031
steps:
32+
- name: Get repository from pull request comment
33+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
34+
id: get-repository
35+
with:
36+
github-token: ${{secrets.GITHUB_TOKEN}}
37+
script: |
38+
const pull = await github.rest.pulls.get({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
pull_number: context.issue.number
42+
});
43+
44+
const repositoryName = pull.data.head?.repo?.full_name
45+
console.log(repositoryName)
46+
return repositoryName
47+
48+
- name: Disabled on forks
49+
if: ${{ fromJSON(steps.get-repository.outputs.result) != github.repository }}
50+
run: |
51+
echo 'Can not execute /compile on forks'
52+
exit 1
53+
2154
- name: Check actor permission
2255
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v2
2356
with:
@@ -29,10 +62,10 @@ jobs:
2962
token: ${{ secrets.COMMAND_BOT_PAT }}
3063
repository: ${{ github.event.repository.full_name }}
3164
comment-id: ${{ github.event.comment.id }}
32-
reactions: "+1"
65+
reactions: '+1'
3366

3467
- name: Parse command
35-
uses: skjnldsv/parse-command-comment@d8c0034c481b791dd6348fcacd9c510dc3a4cb4f # v2
68+
uses: skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
3669
id: command
3770

3871
# Init path depending on which command is run
@@ -46,53 +79,64 @@ jobs:
4679
fi
4780
4881
- name: Init branch
49-
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
82+
uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0
5083
id: comment-branch
5184

85+
- name: Add reaction on failure
86+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
87+
if: failure()
88+
with:
89+
token: ${{ secrets.COMMAND_BOT_PAT }}
90+
repository: ${{ github.event.repository.full_name }}
91+
comment-id: ${{ github.event.comment.id }}
92+
reactions: '-1'
93+
5294
process:
5395
runs-on: ubuntu-latest
5496
needs: init
5597

5698
steps:
5799
- name: Restore cached git repository
58-
uses: buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
100+
uses: buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
59101
with:
60102
path: .git
61103
key: git-repo
62104

63105
- name: Checkout ${{ needs.init.outputs.head_ref }}
64-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
106+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65107
with:
108+
# Needed to allow force push later
109+
persist-credentials: true
66110
token: ${{ secrets.COMMAND_BOT_PAT }}
67111
fetch-depth: 0
68112
ref: ${{ needs.init.outputs.head_ref }}
69113

70114
- name: Setup git
71115
run: |
72-
git config --local user.email "nextcloud-command@users.noreply.github.com"
73-
git config --local user.name "nextcloud-command"
116+
git config --local user.email 'nextcloud-command@users.noreply.github.com'
117+
git config --local user.name 'nextcloud-command'
74118
75119
- name: Read package.json node and npm engines version
76-
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
120+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
77121
id: package-engines-versions
78122
with:
79123
fallbackNode: '^20'
80124
fallbackNpm: '^10'
81125

82126
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
83-
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v3
127+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
84128
with:
85129
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
86130
cache: npm
87131

88132
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
89-
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
133+
run: npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
90134

91135
- name: Rebase to ${{ needs.init.outputs.base_ref }}
92136
if: ${{ contains(needs.init.outputs.arg1, 'rebase') }}
93137
run: |
94-
git fetch origin ${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}
95-
git rebase origin/${{ needs.init.outputs.base_ref }}
138+
git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
139+
git rebase 'origin/${{ needs.init.outputs.base_ref }}'
96140
97141
- name: Install dependencies & build
98142
env:
@@ -105,30 +149,30 @@ jobs:
105149
- name: Commit default
106150
if: ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
107151
run: |
108-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
152+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
109153
git commit --signoff -m 'chore(assets): Recompile assets'
110154
111155
- name: Commit fixup
112156
if: ${{ contains(needs.init.outputs.arg1, 'fixup') }}
113157
run: |
114-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
158+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
115159
git commit --fixup=HEAD --signoff
116160
117161
- name: Commit amend
118162
if: ${{ contains(needs.init.outputs.arg1, 'amend') }}
119163
run: |
120-
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
164+
git add '${{ github.workspace }}${{ needs.init.outputs.git_path }}'
121165
git commit --amend --no-edit --signoff
122166
# Remove any [skip ci] from the amended commit
123167
git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
124-
168+
125169
- name: Push normally
126170
if: ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
127-
run: git push origin ${{ needs.init.outputs.head_ref }}
171+
run: git push origin '${{ needs.init.outputs.head_ref }}'
128172

129173
- name: Force push
130174
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
131-
run: git push --force origin ${{ needs.init.outputs.head_ref }}
175+
run: git push --force origin '${{ needs.init.outputs.head_ref }}'
132176

133177
- name: Add reaction on failure
134178
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
@@ -137,4 +181,4 @@ jobs:
137181
token: ${{ secrets.COMMAND_BOT_PAT }}
138182
repository: ${{ github.event.repository.full_name }}
139183
comment-id: ${{ github.event.comment.id }}
140-
reactions: "-1"
184+
reactions: '-1'

0 commit comments

Comments
 (0)