evergreen #46
This file contains hidden or 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: evergreen | |
on: | |
schedule: | |
- cron: '0 7 * * */5' # At 7:00 on every 5th day of week | |
workflow_dispatch: | |
# Limit one run for each branch to avoid hazards | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
evergreen: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
persist-credentials: 'true' | |
- uses: DeterminateSystems/nix-installer-action@main | |
with: | |
extra-conf: | | |
accept-flake-config = true | |
experimental-features = nix-command flakes | |
builders-use-substitutes = true | |
- name: Update nix flake | |
run: nix flake update >> $GITHUB_STEP_SUMMARY | |
- name: Push changes | |
id: push | |
run: | | |
if [[ `git status flake.lock --porcelain` ]]; then | |
git config user.name github-actions[bot] | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git add flake.lock | |
git commit -m "bot: nix flake update" | |
git push | |
echo "trigger_build=1" >> $GITHUB_OUTPUT | |
else | |
echo "flake.lock is not changed..." | |
echo "trigger_build=0" >> $GITHUB_OUTPUT | |
fi | |
- name: Trigger build | |
uses: actions/github-script@v7 | |
if: steps.push.outputs.trigger_build == '1' | |
with: | |
script: |- | |
github.rest.repos.createDispatchEvent({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
event_type: 'build', | |
}); |