tokei: removal #197
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow gets the list of all changed .spec files, | |
# and triggers a rebuild on COPR for each of them via webhook. | |
name: Rebuild changed packages on COPR | |
on: | |
push: | |
branches: | |
- master | |
- cicd-testing | |
workflow_dispatch: | |
jobs: | |
trigger-rebuild-for-modified: | |
name: Trigger rebuild for modified .spec files | |
runs-on: ubuntu-latest | |
timeout-minutes: 3 | |
outputs: | |
builds: ${{ steps.send-request.outputs.builds }} | |
steps: | |
- name: Install ripgrep | |
run: sudo apt-get install -y ripgrep | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get modified .spec files | |
id: spec-modified | |
uses: tj-actions/changed-files@v39 | |
with: | |
files: specs/*.spec | |
- name: Send rebuild request to COPR | |
id: send-request | |
env: | |
URL: ${{ secrets.COPR_WEBHOOK_URL }} | |
run: | | |
BUILD_IDS=() | |
for FILE in ${{ steps.spec-modified.outputs.modified_files }}; do | |
PKG=$(rg '^Name:\s*([\w\d_\-]+)\s*$' --replace '$1' $FILE) | |
echo "Package $PKG changed (Spec file: $FILE); sending rebuild request" | |
BUILD_ID=$(curl -Ssf -X POST "$URL/$PKG") | |
echo "Build submitted: https://copr.fedorainfracloud.org/coprs/build/$BUILD_ID" | |
BUILD_IDS+=( "$BUILD_ID" ) | |
done | |
echo "builds=$(printf '%s\n' "${BUILD_IDS[@]}" | jq -ncR '[inputs] | map(select(. != ""))')" >> "$GITHUB_OUTPUT" | |
report-status: | |
name: Report build status | |
needs: trigger-rebuild-for-modified | |
runs-on: ubuntu-latest | |
if: needs.trigger-rebuild-for-modified.outputs.builds != '[]' | |
strategy: | |
fail-fast: false | |
matrix: | |
build_id: ${{ fromJson(needs.trigger-rebuild-for-modified.outputs.builds) }} | |
steps: | |
- name: Report status | |
run: | | |
while true; do | |
STATUS=$(curl -Ssf "https://copr.fedorainfracloud.org/api_3/build/${{ matrix.build_id }}" | jq -r '.state') | |
case $STATUS in | |
pending | starting | importing | imported | waiting | running) | |
echo "Build is $STATUS. Querying again in 15s." | |
sleep 15 | |
;; | |
succeeded | forked) | |
echo "Build $STATUS." | |
exit 0 | |
;; | |
failed | canceled | skipped) | |
echo "Build $STATUS." | |
exit 1 | |
;; | |
*) | |
echo "COPR API reported unknown status: $STATUS." | |
exit 2 | |
;; | |
esac | |
done |