diff --git a/.github/workflows/run-obs.yml b/.github/workflows/run-obs.yml index c1527068..4cec54ec 100644 --- a/.github/workflows/run-obs.yml +++ b/.github/workflows/run-obs.yml @@ -115,6 +115,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + pull-requests: write if: | github.event_name == 'workflow_dispatch' || needs.check-updates.outputs.has_updates == 'true' @@ -124,6 +125,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - name: Determine packages to update id: packages @@ -295,35 +297,59 @@ jobs: bash distro/scripts/obs-upload.sh "$PACKAGES" "$MESSAGE" fi - - name: Commit changelog and spec updates + - name: Get changed packages + id: changed-packages run: | - # Configure git user for commits - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - # Check if there are any changes to commit if git diff --exit-code distro/debian/ distro/opensuse/ >/dev/null 2>&1; then + echo "has_changes=false" >> $GITHUB_OUTPUT echo "📋 No changelog or spec changes to commit" else + echo "has_changes=true" >> $GITHUB_OUTPUT # Get list of changed packages for commit message CHANGED_DEB=$(git diff --name-only distro/debian/ 2>/dev/null | grep 'debian/changelog' | xargs dirname 2>/dev/null | xargs dirname 2>/dev/null | xargs basename 2>/dev/null | tr '\n' ', ' | sed 's/, $//' || echo "") CHANGED_SUSE=$(git diff --name-only distro/opensuse/ 2>/dev/null | grep '\.spec$' | sed 's|distro/opensuse/||' | sed 's/\.spec$//' | tr '\n' ', ' | sed 's/, $//' || echo "") - CHANGED="" - [ -n "$CHANGED_DEB" ] && CHANGED="Debian: $CHANGED_DEB" - [ -n "$CHANGED_SUSE" ] && [ -n "$CHANGED" ] && CHANGED="$CHANGED | " - [ -n "$CHANGED_SUSE" ] && CHANGED="${CHANGED}OpenSUSE: $CHANGED_SUSE" - PKGS=$(echo "$CHANGED_DEB,$CHANGED_SUSE" | tr ',' '\n' | grep -v '^$' | sort -u | tr '\n' ',' | sed 's/,$//') - - echo "📋 Committing changelog and spec updates for: $PKGS" - - git add distro/debian/ distro/opensuse/ - git commit -m "ci: Auto-update OBS packages [$PKGS]" -m "🤖 Automated by GitHub Actions" - - git push + echo "packages=$PKGS" >> $GITHUB_OUTPUT + echo "📋 Changed packages: $PKGS" fi + - name: Prepare PR body + if: steps.changed-packages.outputs.has_changes == 'true' + id: pr-body + run: | + { + echo 'body<> $GITHUB_OUTPUT + + - name: Create Pull Request + if: steps.changed-packages.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "ci: Auto-update OBS packages [${{ steps.changed-packages.outputs.packages }}]" + title: "ci: Auto-update OBS packages [${{ steps.changed-packages.outputs.packages }}]" + body: ${{ steps.pr-body.outputs.body }} + branch: ci/obs-package-update + delete-branch: true + labels: | + automated + ci + path: | + distro/debian/ + distro/opensuse/ + - name: Summary run: | echo "### OBS Package Update Complete" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/run-ppa.yml b/.github/workflows/run-ppa.yml index b16aac00..1510cda0 100644 --- a/.github/workflows/run-ppa.yml +++ b/.github/workflows/run-ppa.yml @@ -75,6 +75,9 @@ jobs: name: Upload to PPA needs: check-updates runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write if: | github.event_name == 'workflow_dispatch' || needs.check-updates.outputs.has_updates == 'true' @@ -84,6 +87,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v5 @@ -179,27 +183,52 @@ jobs: bash distro/scripts/ppa-upload.sh "$PACKAGES" "$PPA_NAME" questing "${BUILD_ARGS[@]}" fi - - name: Commit changelog updates + - name: Get changed packages + id: changed-packages run: | - # Configure git user for commits - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - # Check if there are any changelog changes to commit if git diff --exit-code distro/ubuntu/ >/dev/null 2>&1; then + echo "has_changes=false" >> $GITHUB_OUTPUT echo "📋 No changelog changes to commit" else + echo "has_changes=true" >> $GITHUB_OUTPUT # Get list of changed packages for commit message - CHANGED=$(git diff --name-only distro/ubuntu/ | grep 'debian/changelog' | xargs dirname | xargs -I{} basename {} | tr '\n' ', ' | sed 's/,$//') - - echo "📋 Committing changelog updates for: $CHANGED" - - git add distro/ubuntu/ - git commit -m "ci: Auto-update PPA packages [$CHANGED]" -m "🤖 Automated by GitHub Actions" - - git push + CHANGED=$(git diff --name-only distro/ubuntu/ | grep 'debian/changelog' | xargs dirname | xargs -I{} basename {} | tr '\n' ',' | sed 's/,$//') + echo "packages=$CHANGED" >> $GITHUB_OUTPUT + echo "📋 Changed packages: $CHANGED" fi + - name: Prepare PR body + if: steps.changed-packages.outputs.has_changes == 'true' + id: pr-body + run: | + { + echo 'body<> $GITHUB_OUTPUT + + - name: Create Pull Request + if: steps.changed-packages.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "ci: Auto-update PPA packages [${{ steps.changed-packages.outputs.packages }}]" + title: "ci: Auto-update PPA packages [${{ steps.changed-packages.outputs.packages }}]" + body: ${{ steps.pr-body.outputs.body }} + branch: ci/ppa-changelog-update + delete-branch: true + labels: | + automated + ci + path: | + distro/ubuntu/ + - name: Summary run: | echo "### PPA Package Upload Complete" >> $GITHUB_STEP_SUMMARY