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
+
1
9
name : Compile Command
2
10
on :
3
11
issue_comment :
@@ -15,109 +23,157 @@ jobs:
15
23
arg1 : ${{ steps.command.outputs.arg1 }}
16
24
arg2 : ${{ steps.command.outputs.arg2 }}
17
25
head_ref : ${{ steps.comment-branch.outputs.head_ref }}
26
+ base_ref : ${{ steps.comment-branch.outputs.base_ref }}
18
27
19
28
steps :
29
+ - name : Get repository from pull request comment
30
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
31
+ id : get-repository
32
+ with :
33
+ github-token : ${{secrets.GITHUB_TOKEN}}
34
+ script : |
35
+ const pull = await github.rest.pulls.get({
36
+ owner: context.repo.owner,
37
+ repo: context.repo.repo,
38
+ pull_number: context.issue.number
39
+ });
40
+
41
+ const repositoryName = pull.data.head?.repo?.full_name
42
+ console.log(repositoryName)
43
+ return repositoryName
44
+
45
+ - name : Disabled on forks
46
+ if : ${{ fromJSON(steps.get-repository.outputs.result) != github.repository }}
47
+ run : |
48
+ echo 'Can not execute /compile on forks'
49
+ exit 1
50
+
20
51
- name : Check actor permission
21
- uses : skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2
52
+ uses : skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v2
22
53
with :
23
54
require : write
24
55
25
56
- name : Add reaction on start
26
- uses : peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3 .0.2
57
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
27
58
with :
28
59
token : ${{ secrets.COMMAND_BOT_PAT }}
29
60
repository : ${{ github.event.repository.full_name }}
30
61
comment-id : ${{ github.event.comment.id }}
31
- reactions : " +1 "
62
+ reactions : ' +1 '
32
63
33
64
- name : Parse command
34
- uses : skjnldsv/parse-command-comment@7cef1df370a99dfd5bf896d50121390c96785db8 # v2
65
+ uses : skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
35
66
id : command
36
67
37
68
# Init path depending on which command is run
38
69
- name : Init path
39
70
id : git-path
40
71
run : |
41
72
if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then
42
- echo "path=${{ github.workspace }}${{ steps.command.outputs.arg1}}" >> $GITHUB_OUTPUT
73
+ echo "path=${{steps.command.outputs.arg1}}" >> $GITHUB_OUTPUT
43
74
else
44
- echo "path=${{ github.workspace }}${{ steps.command.outputs.arg2}}" >> $GITHUB_OUTPUT
75
+ echo "path=${{steps.command.outputs.arg2}}" >> $GITHUB_OUTPUT
45
76
fi
46
77
47
78
- name : Init branch
48
79
uses : xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
49
80
id : comment-branch
50
81
82
+ - name : Add reaction on failure
83
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
84
+ if : failure()
85
+ with :
86
+ token : ${{ secrets.COMMAND_BOT_PAT }}
87
+ repository : ${{ github.event.repository.full_name }}
88
+ comment-id : ${{ github.event.comment.id }}
89
+ reactions : ' -1'
90
+
51
91
process :
52
92
runs-on : ubuntu-latest
53
93
needs : init
54
94
55
95
steps :
56
96
- name : Restore cached git repository
57
- uses : actions /cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
97
+ uses : buildjet /cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
58
98
with :
59
99
path : .git
60
100
key : git-repo
61
101
62
102
- name : Checkout ${{ needs.init.outputs.head_ref }}
63
- uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
103
+ uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
64
104
with :
65
105
token : ${{ secrets.COMMAND_BOT_PAT }}
66
106
fetch-depth : 0
67
107
ref : ${{ needs.init.outputs.head_ref }}
68
108
69
109
- name : Setup git
70
110
run : |
71
- git config --local user.email " nextcloud-command@users.noreply.github.com"
72
- git config --local user.name " nextcloud-command"
111
+ git config --local user.email ' nextcloud-command@users.noreply.github.com'
112
+ git config --local user.name ' nextcloud-command'
73
113
74
114
- name : Read package.json node and npm engines version
75
- uses : skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
115
+ uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
76
116
id : package-engines-versions
77
117
with :
78
118
fallbackNode : ' ^20'
79
- fallbackNpm : ' ^9 '
119
+ fallbackNpm : ' ^10 '
80
120
81
121
- name : Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
82
- uses : actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
122
+ uses : actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
83
123
with :
84
124
node-version : ${{ steps.package-engines-versions.outputs.nodeVersion }}
85
125
cache : npm
86
126
87
127
- name : Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
88
- run : npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
128
+ run : npm i -g 'npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
129
+
130
+ - name : Rebase to ${{ needs.init.outputs.base_ref }}
131
+ if : ${{ contains(needs.init.outputs.arg1, 'rebase') }}
132
+ run : |
133
+ git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
134
+ git rebase 'origin/${{ needs.init.outputs.base_ref }}'
89
135
90
136
- name : Install dependencies & build
137
+ env :
138
+ CYPRESS_INSTALL_BINARY : 0
139
+ PUPPETEER_SKIP_DOWNLOAD : true
91
140
run : |
92
141
npm ci
93
142
npm run build --if-present
94
143
95
- - name : Commit and push default
96
- if : ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
144
+ - name : Commit default
145
+ if : ${{ !contains( needs.init.outputs.arg1, 'fixup') && !contains( needs.init.outputs.arg1, 'amend') }}
97
146
run : |
98
- git add ${{ needs.init.outputs.git_path }}
147
+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
99
148
git commit --signoff -m 'chore(assets): Recompile assets'
100
- git push origin ${{ needs.init.outputs.head_ref }}
101
-
102
- - name : Commit and push fixup
103
- if : ${{ needs.init.outputs.arg1 == 'fixup' }}
149
+
150
+ - name : Commit fixup
151
+ if : ${{ contains(needs.init.outputs.arg1, 'fixup') }}
104
152
run : |
105
- git add ${{ needs.init.outputs.git_path }}
153
+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
106
154
git commit --fixup=HEAD --signoff
107
- git push origin ${{ needs.init.outputs.head_ref }}
108
155
109
- - name : Commit and push amend
110
- if : ${{ needs.init.outputs.arg1 == 'amend' }}
156
+ - name : Commit amend
157
+ if : ${{ contains( needs.init.outputs.arg1, 'amend') }}
111
158
run : |
112
- git add ${{ needs.init.outputs.git_path }}
159
+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
113
160
git commit --amend --no-edit --signoff
114
- git push --force origin ${{ needs.init.outputs.head_ref }}
161
+ # Remove any [skip ci] from the amended commit
162
+ git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
163
+
164
+ - name : Push normally
165
+ if : ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
166
+ run : git push origin '${{ needs.init.outputs.head_ref }}'
167
+
168
+ - name : Force push
169
+ if : ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
170
+ run : git push --force origin '${{ needs.init.outputs.head_ref }}'
115
171
116
172
- name : Add reaction on failure
117
- uses : peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3 .0.2
173
+ uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
118
174
if : failure()
119
175
with :
120
176
token : ${{ secrets.COMMAND_BOT_PAT }}
121
177
repository : ${{ github.event.repository.full_name }}
122
178
comment-id : ${{ github.event.comment.id }}
123
- reactions : " -1 "
179
+ reactions : ' -1 '
0 commit comments