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+
19name : Compile Command
210on :
311 issue_comment :
412 types : [created]
513
14+ permissions :
15+ contents : read
16+
617jobs :
718 init :
8- runs-on : ubuntu-latest
19+ runs-on : ubuntu-latest-low
920
1021 # On pull requests and if the comment starts with `/compile`
1122 if : github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
1930
2031 steps :
2132 - name : Get repository from pull request comment
22- uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 .0.1
33+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 .0.0
2334 id : get-repository
2435 with :
2536 github-token : ${{secrets.GITHUB_TOKEN}}
@@ -46,12 +57,12 @@ jobs:
4657 require : write
4758
4859 - name : Add reaction on start
49- uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
60+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 .0.0
5061 with :
5162 token : ${{ secrets.COMMAND_BOT_PAT }}
5263 repository : ${{ github.event.repository.full_name }}
5364 comment-id : ${{ github.event.comment.id }}
54- reactions : " +1 "
65+ reactions : ' +1 '
5566
5667 - name : Parse command
5768 uses : skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
@@ -68,53 +79,98 @@ jobs:
6879 fi
6980
7081 - name : Init branch
71- uses : xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
82+ uses : xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v3.0.0
7283 id : comment-branch
7384
85+ - name : Add reaction on failure
86+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.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+
7494 process :
7595 runs-on : ubuntu-latest
7696 needs : init
7797
7898 steps :
7999 - name : Restore cached git repository
80- uses : buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
100+ uses : buildjet/cache@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2
81101 with :
82102 path : .git
83103 key : git-repo
84104
85105 - name : Checkout ${{ needs.init.outputs.head_ref }}
86- uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
106+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
87107 with :
108+ # Needed to allow force push later
109+ persist-credentials : true
88110 token : ${{ secrets.COMMAND_BOT_PAT }}
89111 fetch-depth : 0
90112 ref : ${{ needs.init.outputs.head_ref }}
91113
92114 - name : Setup git
93115 run : |
94- git config --local user.email " nextcloud-command@users.noreply.github.com"
95- 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'
96118
97119 - name : Read package.json node and npm engines version
98- uses : skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
120+ uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
99121 id : package-engines-versions
100122 with :
101- fallbackNode : ' ^20 '
102- fallbackNpm : ' ^10 '
123+ fallbackNode : ' ^24 '
124+ fallbackNpm : ' ^11.3 '
103125
104126 - name : Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
105- uses : actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
127+ uses : actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
106128 with :
107129 node-version : ${{ steps.package-engines-versions.outputs.nodeVersion }}
108130 cache : npm
109131
110132 - name : Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
111- run : npm i -g npm@" ${{ steps.package-engines-versions.outputs.npmVersion }}"
133+ run : npm i -g ' npm@${{ steps.package-engines-versions.outputs.npmVersion }}'
112134
113135 - name : Rebase to ${{ needs.init.outputs.base_ref }}
114136 if : ${{ contains(needs.init.outputs.arg1, 'rebase') }}
115137 run : |
116- git fetch origin ${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}
117- git rebase origin/${{ needs.init.outputs.base_ref }}
138+ git fetch origin '${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}'
139+
140+ # Start the rebase
141+ git rebase 'origin/${{ needs.init.outputs.base_ref }}' || {
142+ # Handle rebase conflicts in a loop
143+ while [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; do
144+ echo "Handling rebase conflict..."
145+
146+ # Remove and checkout /dist and /js folders from the base branch
147+ if [ -d "dist" ]; then
148+ rm -rf dist
149+ git checkout origin/${{ needs.init.outputs.base_ref }} -- dist/ 2>/dev/null || echo "No dist folder in base branch"
150+ fi
151+ if [ -d "js" ]; then
152+ rm -rf js
153+ git checkout origin/${{ needs.init.outputs.base_ref }} -- js/ 2>/dev/null || echo "No js folder in base branch"
154+ fi
155+
156+ # Stage all changes
157+ git add .
158+
159+ # Check if there are any changes after resolving conflicts
160+ if git diff --cached --quiet; then
161+ echo "No changes after conflict resolution, skipping commit"
162+ git rebase --skip
163+ else
164+ echo "Changes found, continuing rebase without editing commit message"
165+ git -c core.editor=true rebase --continue
166+ fi
167+
168+ # Break if rebase is complete
169+ if [ ! -d .git/rebase-merge ] && [ ! -d .git/rebase-apply ]; then
170+ break
171+ fi
172+ done
173+ }
118174
119175 - name : Install dependencies & build
120176 env :
@@ -127,36 +183,40 @@ jobs:
127183 - name : Commit default
128184 if : ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
129185 run : |
130- git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
186+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
131187 git commit --signoff -m 'chore(assets): Recompile assets'
132188
133189 - name : Commit fixup
134190 if : ${{ contains(needs.init.outputs.arg1, 'fixup') }}
135191 run : |
136- git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
192+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
137193 git commit --fixup=HEAD --signoff
138194
139195 - name : Commit amend
140196 if : ${{ contains(needs.init.outputs.arg1, 'amend') }}
141197 run : |
142- git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
198+ git add ' ${{ github.workspace }}${{ needs.init.outputs.git_path }}'
143199 git commit --amend --no-edit --signoff
144200 # Remove any [skip ci] from the amended commit
145201 git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
146202
147203 - name : Push normally
148204 if : ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
149- run : git push origin ${{ needs.init.outputs.head_ref }}
205+ env :
206+ HEAD_REF : ${{ needs.init.outputs.head_ref }}
207+ run : git push origin "$HEAD_REF"
150208
151209 - name : Force push
152210 if : ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
153- run : git push --force origin ${{ needs.init.outputs.head_ref }}
211+ env :
212+ HEAD_REF : ${{ needs.init.outputs.head_ref }}
213+ run : git push --force-with-lease origin "$HEAD_REF"
154214
155215 - name : Add reaction on failure
156- uses : peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 .0.0
216+ uses : peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 .0.0
157217 if : failure()
158218 with :
159219 token : ${{ secrets.COMMAND_BOT_PAT }}
160220 repository : ${{ github.event.repository.full_name }}
161221 comment-id : ${{ github.event.comment.id }}
162- reactions : " -1 "
222+ reactions : ' -1 '
0 commit comments