Update flakes #463
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: "Update flakes" | |
on: | |
schedule: | |
- cron: "0 23 * * *" | |
workflow_dispatch: # click the button on Github repo! | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
- uses: DeterminateSystems/nix-installer-action@v15 | |
- uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- run: nix flake update | |
- name: Commit changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
FILE_TO_COMMIT: flake.lock | |
DESTINATION_BRANCH: main | |
run: | | |
export TODAY=$( date -u '+%Y-%m-%d' ) | |
export MESSAGE="Flake update" | |
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT ) | |
export CONTENT=$( base64 -i $FILE_TO_COMMIT ) | |
if git diff --quiet flake.lock; then | |
exit 0 | |
fi | |
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ | |
--field message="$MESSAGE" \ | |
--field content="$CONTENT" \ | |
--field encoding="base64" \ | |
--field branch="$DESTINATION_BRANCH" \ | |
--field sha="$SHA" |