Dependency Updates #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dependency Updates | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup coursier cache | |
uses: coursier/cache-action@v6.4 | |
- name: Setup Scala CLI | |
uses: VirtusLab/scala-cli-setup@v1.5 | |
- name: Check if branch exists on remote | |
id: branch-check | |
run: | | |
if git ls-remote --exit-code --heads origin dependency-update; then | |
echo "branch_exists=true" >> $GITHUB_ENV | |
else | |
echo "branch_exists=false" >> $GITHUB_ENV | |
fi | |
- name: Track or create branch | |
run: | | |
if [ "$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 | |
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 "No changes to commit" | |
- name: Push changes | |
run: | | |
git push -u origin dependency-update | |
- name: Create a Pull Request | |
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" |