Skip to content

Commit

Permalink
update GHA to auto merge/close update pr
Browse files Browse the repository at this point in the history
  • Loading branch information
alterationx10 committed Jan 23, 2025
1 parent 846817d commit 81d14dc
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,58 @@ jobs:
- name: Track or create branch
run: |
if [ "$branch_exists" = "true" ]; then
if [ "${{ env.branch_exists }}" = "true" ]; then
git fetch origin dependency-update:dependency-update
git checkout dependency-update
else
git checkout -b dependency-update
fi
- name: Update dependencies
id: update-deps
run: |
scala-cli --power dependency-update branch --all
git config --global user.name "Mark Rudolph"
git config --global user.email "mark@k8ty.app"
git commit -am "Update dependencies" && echo "changes_exists=true" >> $GITHUB_ENV || echo "No changes to commit" && echo "changes_exists=false" >> $GITHUB_ENV
if git commit -am "Update dependencies"; then
echo "changes_exists=true" >> $GITHUB_ENV
else
echo "changes_exists=false" >> $GITHUB_ENV
fi
- name: Push changes
if: env.changes_exists == 'true'
run: |
git push -u origin dependency-update
- name: Create a Pull Request
if: env.changes_exists == 'true'
run: |
gh pr create \
--title "Dependency Updates" \
--body "Dependency updates from scala-cli" \
--head dependency-update \
--base main || echo "Pull request already exists or no changes to push"
- name: Trigger PR Tests
- uses: docker/setup-buildx-action@v3
- name: PR Tests
if: env.changes_exists == 'true'
run: |
if [ "$changes_exists" = "true" ]; then
gh workflow run pr-tests.yaml || echo "Error running PR tests"
gh pr comment --body "Running PR tests..."
if scala-cli --power test branch; then
echo "tests_passed=true" >> $GITHUB_ENV
else
echo "No changes; not running PR tests"
fi
echo "tests_passed=true" >> $GITHUB_ENV
fi
- name: Merge PR
if: env.tests_passed == 'true'
run: |
gh pr comment --body "PR tests passed! Auto merging..."
gh pr merge --squash --delete-branch --body "Auto-merged dependency updates"
- name: Close PR
if: env.tests_passed == 'false'
run: |
gh pr comment --body "PR tests failed :cry: Closing PR..."
gh pr close --delete-branch --body "PR tests failed"

0 comments on commit 81d14dc

Please sign in to comment.