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 :
819 runs-on : ubuntu-latest
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