Skip to content

Commit

Permalink
chore(ci): daily update check
Browse files Browse the repository at this point in the history
  • Loading branch information
PVermeer committed Dec 7, 2024
1 parent 2477c00 commit a309387
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/update-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Daily COPR

on:
schedule:
- cron: "30 6 * * 1-5"
workflow_dispatch:

jobs:
update_rpm:
runs-on: ubuntu-latest
name: Update RPM
env:
UPDATE_STATUS: "current"

steps:
- uses: actions/checkout@v4

- name: Update RPM
run: |
source ./scripts/update-rpm.sh
echo "UPDATE_STATUS=$update_status" >> $GITHUB_ENV
- uses: zyrouge/github-push-action@v1
if: ${{ env.UPDATE_STATUS == 'updated' }}
with:
commit-message: "build(github-actions): automated update [skip ci]"
allow-empty-commit: false

- name: Build on COPR
if: ${{ env.UPDATE_STATUS == 'updated' }}
env:
COPR_WEBHOOK: ${{ secrets.COPR_WEBHOOK }}
run: |
curl -X POST $COPR_WEBHOOK
26 changes: 26 additions & 0 deletions scripts/update-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

update_rpm() {
local spec_file=./chromebook-linux-audio.spec

local current_main_commit=$(grep '%global maincommit\s.*$' $spec_file | awk '{ print $3 }')
local current_dep_commit=$(grep '%global depcommit\s.*$' $spec_file | awk '{ print $3 }')

local new_main_commit=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/WeirdTreeThing/chromebook-linux-audio/commits/HEAD")
local new_dep_commit=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/WeirdTreeThing/alsa-ucm-conf-cros/commits/HEAD")

if [ "$current_main_commit" = "$new_main_commit" ] && [ "$current_dep_commit" = "$new_dep_commit" ]; then

echo "No changes detected"
else
echo "Changes detected, updating RPM spec"

sed -i -e "s/maincommit\s.*/maincommit $new_main_commit/" ./$spec_file
sed -i -e "s/depcommit\s.*/depcommit $new_dep_commit/" ./$spec_file

update_status="updated"
fi
}

update_status="current"
update_rpm

0 comments on commit a309387

Please sign in to comment.