Skip to content

Commit

Permalink
Check dependencies automatically once a day (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Oct 28, 2024
1 parent 75ba04e commit f197406
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/check-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash -e

GITHUB_PR_LABEL="dependencies"

if [ -z "$BRANCH_NAME" ]; then
echo "Branch name is required"
exit 1
fi

function check_pr {
gh pr list --state open --label "$GITHUB_PR_LABEL"
}

git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

_update_output="$(TERM=dumb rebar3 update-deps --replace)"

if git diff --exit-code --quiet; then
echo "No changes to the dependencies"
exit 0
fi

git checkout -b "$BRANCH_NAME"
git add .

git commit -F- <<EOF
Update dependencies
Updates from "rebar3 update-deps --replace":
$_update_output
EOF

git push --set-upstream origin "$BRANCH_NAME"

if [[ $(check_pr) == "" ]]; then
gh pr create --fill --label "$GITHUB_PR_LABEL"
fi
41 changes: 41 additions & 0 deletions .github/workflows/check_deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check Dependencies

on:
workflow_dispatch:
schedule:
- cron: '38 8 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-deps:
name: Check Dependencies
runs-on: ubuntu-22.04
strategy:
matrix:
otp_version: ['27.1']

steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
version-type: 'strict'

- uses: actions/cache@v4
with:
path: |
~/.cache/rebar3
_build
key: ${{ runner.os }}-erlang-${{ matrix.otp_version }}-${{ hashFiles('**/*rebar.lock') }}

- name: Build
run: make build

- name: Check dependencies
run: .github/workflows/check-deps.sh
env:
BRANCH_NAME: update-deps-${{ github.run_id }}

0 comments on commit f197406

Please sign in to comment.