From ee76acc9c938a070ab82bec48ea4f0df35470402 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 18 Sep 2024 09:05:36 +0200 Subject: [PATCH] Update rosdistro only when necessary --- .github/workflows/update.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 1c4661e..26ca830 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,7 +1,7 @@ name: Update rosdistro on: schedule: - - cron: "0 12 * * FRI" + - cron: "0 12 * * *" workflow_dispatch: jobs: update: @@ -15,7 +15,26 @@ jobs: git config user.email 'github-actions[bot]@users.noreply.github.com' - name: Update rosdistro run: | - nix flake update rosdistro --commit-lock-file + nix build .#rosdistro --out-link /tmp/rosdistro-old + nix flake update rosdistro + nix build .#rosdistro --out-link /tmp/rosdistro-new + grep -Rh nixos: /tmp/rosdistro-old > /tmp/rosdistro-old.txt + grep -Rh nixos: /tmp/rosdistro-new > /tmp/rosdistro-new.txt + git reset --hard + if ! git diff /tmp/rosdistro-old.txt /tmp/rosdistro-new.txt > /tmp/rosdistro-diff; then + # redo update with nice commit message + nix flake update rosdistro --commit-lock-file + GIT_EDITOR='sed -i -e "1crosdistro update"' git commit --amend + GIT_EDITOR='sed -i -e "\$R/tmp/rosdistro-diff"' git commit --amend + cat < /tmp/.body + Diff: + ```diff + $(cat /tmp/rosdistro-diff) + ``` + EOF + else + echo "No relevant changes" + fi git show --format='%b' --no-patch > /tmp/.body - name: Create Pull Request uses: peter-evans/create-pull-request@v7