... on scheduled GitHub Actions.
This is an example scheduled-based workflow to run a .sh
at a given time of day.
---
name: Update dependencies
"on":
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
jobs:
update:
name: Update dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: 26
rebar3-version: 3
- run: ./.github/workflows/rebar3_depup.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
(the GITHUB_TOKEN
is required to allow github-actions
to open pull requests to your repository)
This is an example .sh
that opens a specific Git branch, updates the deps. (rebar3
alias up
) and creates a pull request with changes, if any.
#!/usr/bin/env bash
set -eux
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git fetch origin
BRANCHES=$(git branch -a)
BRANCH=feature/rebar3-depup-updates
if echo "${BRANCHES}" | grep "${BRANCH}" >/dev/null; then
# exists
exit
fi
git checkout -b "${BRANCH}"
mkdir -p "${HOME}/.config/rebar3"
echo "{plugins, [rebar3_depup]}." > "${HOME}/.config/rebar3/rebar.config"
rebar3 update-deps --replace
rebar3 upgrade --all
if ! git diff --exit-code 1> /dev/null ; then
# there's stuff to push
TITLE="[automation] Update \`rebar.config\` versions (via \`rebar3 depup\`)"
git add rebar.config
git add rebar.lock
git commit -m "${TITLE}"
git push origin "${BRANCH}"
gh pr create --fill \
--title "${TITLE}" \
--body "This is an automated action to update the repository's \`rebar.config\` versions."
fi
(the commits are signed by GitHub Actions / [email protected], and we're using bleeding edge rebar3_depup
)