Skip to content

CD: Auto send rebuild requests to COPR (#1) #9

CD: Auto send rebuild requests to COPR (#1)

CD: Auto send rebuild requests to COPR (#1) #9

# 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
workflow_dispatch:
jobs:
trigger-rebuild-for-modified:
name: Trigger rebuild for modified .spec files
runs-on: ubuntu-latest
timeout-minutes: 3
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
if: ${{ steps.spec-modified.outputs.modified_files_count }} != 0
env:
URL: ${{ secrets.COPR_WEBHOOK_URL }}
run: |
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"
done