Add workflow to update dependencies using dependabot cli #15
Workflow file for this run
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
# | |
# Copyright (C) 2019-2024 vdaas.org vald team <[email protected]> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# You may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
name: Update Gradle dependencies | |
on: | |
# NOTE: for debug | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.CI_TOKEN }} | |
- name: Set Git config | |
run: | | |
git config --global --add safe.directory ${GITHUB_WORKSPACE} | |
- uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Install dependabot CLI | |
run: | | |
# NOTE: https://github.com/dependabot/cli?tab=readme-ov-file#installation | |
gh gist view --raw e09e1ecd76d5573e0517a7622009f06f | bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Update Gradle dependencies | |
run: | | |
dependabot update \ | |
--file .github/dependabot-cli.yaml \ | |
--local . \ | |
--output dependabot-result.yaml | |
RESULT=$(cat dependabot-result.yaml | yq -e '.output.[] | select(.type == "create_pull_request") | .expect.data.updated-dependency-files.[].content' 2>/dev/null) \ | |
&& [ -n "${RESULT}" ] && echo "${RESULT}" > ./build.gradle || true | |
- name: Check difference | |
id: check_diff | |
run: | | |
if git diff --quiet --exit-code; then | |
echo "Nothing updated" | |
else | |
git diff && git status | |
echo "HAS_GIT_DIFF=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Create PR | |
if: ${{ steps.check_diff.outputs.HAS_GIT_DIFF == 'true' }} | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
author: "${{ secrets.CI_USER }} <[email protected]>" | |
token: ${{ secrets.CI_TOKEN }} | |
committer: "${{ secrets.CI_USER }} <[email protected]>" | |
signoff: true | |
delete-branch: true | |
base: main | |
title: "Bump Gradle dependencies updates" | |
body: "Automated pull request to update Gradle dependencies." |