4747 SECRETS_COPR_BETA_WEBHOOK_TOKEN : ${{ secrets.COPR_BETA_WEBHOOK_TOKEN }}
4848 SECRETS_COPR_STABLE_WEBHOOK_TOKEN : ${{ secrets.COPR_STABLE_WEBHOOK_TOKEN }}
4949 SECRETS_COPR_CLI_CONFIG : ${{ secrets.COPR_CLI_CONFIG }}
50+ PACKAGE_NAME : ${{ github.event.repository.name }}
51+ GH_EVENT_ACTION : ${{ github.event.action }}
52+ GH_EVENT_NAME : ${{ github.event_name }}
53+ GH_EVENT_NUMBER : ${{ github.event.number }}
5054
5155jobs :
5256 package-init :
53- name : Create/update copr package
57+ name : Setup
5458 container : fedora:latest
5559 env :
5660 BASE_URL : https://copr.fedorainfracloud.org/api_3
57- PACKAGE_NAME : ${{ github.event.repository.name }}
5861 SOURCE_TYPE_TEXT : " custom"
5962 permissions :
6063 contents : read
8083 echo "Copr CLI configuration file is empty. Exiting..."
8184
8285 # if a pull request exit with 0
83- if [[ "${{ github.event_name } }" = "pull_request" ]]; then
86+ if [[ "${GITHUB_EVENT_NAME }" = "pull_request" ]]; then
8487 echo "SKIP_REMAINING_JOBS=true" >> "${GITHUB_OUTPUT}"
8588 else
8689 exit 1
@@ -107,9 +110,9 @@ jobs:
107110 )
108111
109112 # download the latest copr-ci.sh script
110- if [[ "${{ github.repository } }" = "LizardByte/copr-ci" ]]; then
113+ if [[ "${GITHUB_REPOSITORY }" = "LizardByte/copr-ci" ]]; then
111114 # use the version from the same ref
112- ref="${{ github.ref } }"
115+ ref="${GITHUB_REF }"
113116 else
114117 ref="master" # default to master branch
115118 fi
@@ -153,16 +156,16 @@ jobs:
153156 done
154157
155158 build :
156- name : Copr build
159+ name : Build
157160 if : github.repository_owner == inputs.github_org_owner
158161 container : fedora:latest
159162 needs : package-init
160163 outputs :
161164 BUILD_ID : ${{ steps.build.outputs.BUILD_ID }}
165+ BUILD_CHANNEL : ${{ steps.get-properties.outputs.BUILD_CHANNEL }}
162166 BUILD_CANCEL : ${{ steps.build.outcome == 'cancelled' }}
163167 BUILD_SUCCESS : ${{ steps.build.outcome == 'success' }}
164168 runs-on : ubuntu-latest
165- timeout-minutes : ${{ inputs.job_timeout }}
166169 permissions :
167170 contents : read
168171 steps :
@@ -171,56 +174,32 @@ jobs:
171174 dnf install -y \
172175 copr-cli \
173176 git \
174- jq \
175- nodejs \
176- zip
177+ jq
177178
178179 - name : Checkout
179180 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
180181
181182 - name : Set git safe directory
182183 run : git config --global --add safe.directory '*'
183184
184- - name : Add problem matchers
185- run : |
186- # add default matchers
187- mkdir -p .github/matchers
188-
189- # download the latest rpmlint.json matcher
190- if [[ ! "${{ github.repository }}" = "LizardByte/copr-ci" ]]; then
191- # not in copr-ci repo, so download the rpmlint.json
192- ref="master" # default to master branch
193- curl \
194- -fsS \
195- --retry 3 \
196- "https://raw.githubusercontent.com/lizardbyte/copr-ci/${ref}/.github/matchers/rpmlint.json" \
197- -o ".github/matchers/rpmlint.json"
198- fi
199- echo "::add-matcher::.github/matchers/rpmlint.json"
200-
201- # repo specific matchers
202- if [[ -f ".github/matchers/copr-ci.json" ]]; then
203- echo "Found copr-ci.json matcher, adding it..."
204- echo "::add-matcher::.github/matchers/copr-ci.json"
205- fi
206-
207185 - name : Get properties
186+ id : get-properties
208187 run : |
209188 # package name = repository name
210- package=${{ github.event.repository.name } }
189+ package=${PACKAGE_NAME }
211190 copr_base="https://copr.fedorainfracloud.org/webhooks/custom-dir/${INPUTS_COPR_OWNERNAME}"
212191
213192 # release and released type
214- if [[ "${{ github.event_name } }" = "release" ]]; then
215- if [[ "${{ github.event.action } }" = "prereleased" ]]; then
193+ if [[ "${GH_EVENT_NAME }" = "release" ]]; then
194+ if [[ "${GH_EVENT_ACTION }" = "prereleased" ]]; then
216195 BUILD_CHANNEL="beta"
217196 COPR_PUSH_WEBHOOK="${copr_base}/${BUILD_CHANNEL}/${SECRETS_COPR_BETA_WEBHOOK_TOKEN}/${package}/"
218- elif [[ "${{ github.event.action } }" = "released" ]]; then
197+ elif [[ "${GH_EVENT_ACTION }" = "released" ]]; then
219198 BUILD_CHANNEL="stable"
220199 COPR_PUSH_WEBHOOK="${copr_base}/${BUILD_CHANNEL}/${SECRETS_COPR_STABLE_WEBHOOK_TOKEN}/${package}/"
221200 fi
222- elif [[ "${{ github.event_name } }" = "pull_request" ]]; then
223- BUILD_CHANNEL="pulls:pr:${{ github.event.number } }"
201+ elif [[ "${GH_EVENT_NAME }" = "pull_request" ]]; then
202+ BUILD_CHANNEL="pulls:pr:${GH_EVENT_NUMBER }"
224203 COPR_PR_WEBHOOK="${copr_base}/${BUILD_CHANNEL}/${INPUTS_COPR_PR_WEBHOOK_TOKEN}/${package}/"
225204 fi
226205
@@ -234,8 +213,13 @@ jobs:
234213 echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}"
235214 echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}"
236215
216+ # Output BUILD_CHANNEL for other jobs
217+ echo "BUILD_CHANNEL=${BUILD_CHANNEL}" >> "${GITHUB_OUTPUT}"
218+
237219 - name : Build
238220 id : build
221+ env :
222+ PR_NUMBER : ${{ github.event.pull_request.number }}
239223 run : |
240224 curl \
241225 -fsS \
@@ -245,36 +229,84 @@ jobs:
245229 # "https://raw.githubusercontent.com/praiskup/copr-ci-tooling/main/copr-gh-actions-submit"
246230
247231 # if a PR number is added the script will use the PR webhook, otherwise it will use the push webhook
248- bash submit ${{ github.event.pull_request.number }}
232+ if [[ -n "${PR_NUMBER}" ]]; then
233+ echo "Using PR webhook for build submission..."
234+ bash submit "${PR_NUMBER}"
235+ else
236+ echo "Using push webhook for build submission..."
237+ bash submit
238+ fi
249239
250240 - name : Cancel Copr build
251241 if : >-
252242 always() &&
253243 steps.build.outcome == 'cancelled' &&
254244 github.secret_source
245+ env :
246+ BUILD_ID : ${{ steps.build.outputs.BUILD_ID }}
255247 run : |
256248 mkdir -p ~/.config
257249 echo "${SECRETS_COPR_CLI_CONFIG}" > ~/.config/copr
258250
259251 copr-cli \
260252 cancel \
261- ${{ steps.build.outputs.BUILD_ID }}
253+ "${BUILD_ID}"
254+
255+ logs :
256+ name : Get logs
257+ if : always() && needs.build.outputs.BUILD_ID != ''
258+ container : fedora:latest
259+ env :
260+ BUILD_CHANNEL : ${{ needs.build.outputs.BUILD_CHANNEL }}
261+ BUILD_ID : ${{ needs.build.outputs.BUILD_ID }}
262+ needs : build
263+ runs-on : ubuntu-latest
264+ permissions :
265+ contents : read
266+ steps :
267+ - name : Install dependencies
268+ run : |
269+ dnf install -y \
270+ jq
271+
272+ - name : Checkout
273+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
274+
275+ - name : Add problem matchers
276+ run : |
277+ # add default matchers
278+ mkdir -p .github/matchers
279+
280+ # download the latest rpmlint.json matcher
281+ if [[ ! "${{ github.repository }}" = "LizardByte/copr-ci" ]]; then
282+ # not in copr-ci repo, so download the rpmlint.json
283+ ref="master" # default to master branch
284+ curl \
285+ -fsS \
286+ --retry 3 \
287+ "https://raw.githubusercontent.com/lizardbyte/copr-ci/${ref}/.github/matchers/rpmlint.json" \
288+ -o ".github/matchers/rpmlint.json"
289+ fi
290+ echo "::add-matcher::.github/matchers/rpmlint.json"
291+
292+ # repo specific matchers
293+ if [[ -f ".github/matchers/copr-ci.json" ]]; then
294+ echo "Found copr-ci.json matcher, adding it..."
295+ echo "::add-matcher::.github/matchers/copr-ci.json"
296+ fi
262297
263298 - name : Logs
264- if : >-
265- always() &&
266- steps.build.outcome != 'skipped'
267299 run : |
268- package=${{ github.event.repository.name } }
300+ package=${PACKAGE_NAME }
269301 base_url="https://download.copr.fedorainfracloud.org/results/${INPUTS_COPR_OWNERNAME}/${BUILD_CHANNEL}"
270302
271303 # get chroots and prefixed build_id
272- build_url="https://copr.fedorainfracloud.org/api_3/build/${{ steps.build.outputs. BUILD_ID } }"
304+ build_url="https://copr.fedorainfracloud.org/api_3/build/${BUILD_ID}"
273305 data=$(curl -fsS --retry 3 "${build_url}")
274306
275307 # Extract build_id from source_package.url (matches the last path segment after 'srpm-builds/')
276- build_id =$(echo "${data}" | jq -r '.source_package.url' | sed -E 's#.*/srpm-builds/([0-9]+)/.*#\1#')
277- echo "build_id : ${build_id }"
308+ build_id_alt =$(echo "${data}" | jq -r '.source_package.url' | sed -E 's#.*/srpm-builds/([0-9]+)/.*#\1#')
309+ echo "build_id_alt : ${build_id_alt }"
278310
279311 # Extract chroots
280312 chroots=$(echo "${data}" | jq -r '.chroots[]')
@@ -283,14 +315,14 @@ jobs:
283315
284316 # Array of "name|url" pairs
285317 logs=(
286- "source_builder|${base_url}/srpm-builds/${build_id }/builder-live.log.gz"
287- "source_backend|${base_url}/srpm-builds/${build_id }/backend.log.gz"
288- "import|https://copr-dist-git.fedorainfracloud.org/per-task-logs/${{ steps.build.outputs. BUILD_ID } }.log"
318+ "source_builder|${base_url}/srpm-builds/${build_id_alt }/builder-live.log.gz"
319+ "source_backend|${base_url}/srpm-builds/${build_id_alt }/backend.log.gz"
320+ "import|https://copr-dist-git.fedorainfracloud.org/per-task-logs/${BUILD_ID}.log"
289321 )
290322
291323 for chroot in $chroots; do
292- logs+=("builder_${chroot}|${base_url}/${chroot}/${build_id }-${package}/builder-live.log.gz")
293- logs+=("backend_${chroot}|${base_url}/${chroot}/${build_id }-${package}/backend.log.gz")
324+ logs+=("builder_${chroot}|${base_url}/${chroot}/${build_id_alt }-${package}/builder-live.log.gz")
325+ logs+=("backend_${chroot}|${base_url}/${chroot}/${build_id_alt }-${package}/backend.log.gz")
294326 done
295327
296328 error=0
@@ -311,16 +343,33 @@ jobs:
311343
312344 exit ${error}
313345
346+ artifacts :
347+ name : Artifacts
348+ if : always() && needs.build.outputs.BUILD_SUCCESS == 'true'
349+ container : fedora:latest
350+ env :
351+ BUILD_ID : ${{ needs.build.outputs.BUILD_ID }}
352+ needs : build
353+ runs-on : ubuntu-latest
354+ permissions :
355+ contents : read
356+ steps :
357+ - name : Install dependencies
358+ run : |
359+ dnf install -y \
360+ copr-cli \
361+ nodejs \
362+ zip
363+
314364 - name : Download build
315365 id : download-build
316- if : steps.build.outcome == 'success'
317366 run : |
318367 mkdir -p artifacts
319368 copr-cli \
320369 download-build \
321370 --dest . \
322371 --rpms \
323- ${{ steps.build.outputs. BUILD_ID }}
372+ "${ BUILD_ID}"
324373
325374 - name : Setup gh actions artifact client
326375 id : download-build-client
0 commit comments