From f138c6b2c884e274466c64085c3679358c72297a Mon Sep 17 00:00:00 2001 From: Andrea Mazzotti Date: Mon, 1 Jul 2024 09:49:33 +0200 Subject: [PATCH] [CI] Create a new refresh PR instead of pushing changes (#8) Signed-off-by: Andrea Mazzotti --- .github/workflows/refresh-channels.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/refresh-channels.yaml b/.github/workflows/refresh-channels.yaml index 5a17d2b..9f9656f 100644 --- a/.github/workflows/refresh-channels.yaml +++ b/.github/workflows/refresh-channels.yaml @@ -17,10 +17,19 @@ jobs: fetch-depth: 0 - name: Run refresh script run: ./refresh_channels.sh - - name: Commit and push changes + - name: Open a new PR run: | git config --global user.email "do-not-use@elemental.suse.com" git config --global user.name "GitHub Action Runner" + branch_name="gha-refresh-${{ github.run_id }}-${{ github.run_number}}-${{ github.run_attempt }}" + git switch --force-create "${branch_name}" origin/main git add . - git diff-index --quiet HEAD || git commit -m "Automatic update. Run ID ${{ github.run_id }}, Number ${{ github.run_number}}, Attempt ${{ github.run_attempt }}" - git push origin + + if git diff-index --quiet HEAD; then + echo "No new updates. Nothing to do." + exit 0 + fi + + git commit -m "Automatic update. Run ID ${{ github.run_id }}, Number ${{ github.run_number}}, Attempt ${{ github.run_attempt }}" + git push --force origin "${branch_name}" + gh pr create --fill --head "${branch_name}"