Skip to content

Commit

Permalink
github/update: run update on the respective branch
Browse files Browse the repository at this point in the history
Allows the `update.yml` workflow to just run on the triggered branch without needing inputs.

`update.yml` will use `gh workflow run` to trigger the other branch.
  • Loading branch information
MattSturgeon committed Jul 15, 2024
1 parent abc409c commit 96dd414
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
name: update
on:
workflow_dispatch: # allows manual triggering
inputs:
branch:
description: "Branch to update"
type: choice
options:
- "stable & unstable"
- "main"
- "nixos-24.05"
# Runs every Saturday at noon
schedule:
- cron: "0 12 * * SAT" # runs weekly on Saturday at noon
- cron: "0 12 * * SAT"
# Allow manual triggering
workflow_dispatch:
inputs:
nixos-24.05:
type: boolean
default: false
required: false
description: Also call update on the nixos-24.05 branch

jobs:
lockfile:
strategy:
matrix:
# This allows to update both stable & unstable branches, but not both when triggered
# manually
branch: ["main", "nixos-24.05"]
selectedBranch: ["${{ inputs.branch }}"]
exclude:
- selectedBranch: main
branch: "nixos-24.05"
- selectedBranch: "nixos-24.05"
branch: main

name: Update the flake inputs and generate options
runs-on: ubuntu-latest
timeout-minutes: 40
Expand All @@ -39,7 +27,10 @@ jobs:
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.CI_UPDATE_SSH_KEY }}
ref: ${{ matrix.branch }}

- name: Update nixos-24.05
if: inputs.nixos-24.05 || github.event_name == 'schedule'
run: gh workflow run update.yml --ref nixos-24.05

- name: Install Nix
uses: cachix/install-nix-action@v26
Expand Down Expand Up @@ -82,13 +73,12 @@ jobs:
id: pr
uses: peter-evans/create-pull-request@v6
with:
branch: update/${{ matrix.branch }}
base: ${{ matrix.branch }}
branch: update/${{ github.ref_name }}
delete-branch: true
team-reviewers: |
nix-community/nixvim
title: |
[${{ matrix.branch }}] Update flake.lock & generated files
[${{ github.ref_name }}] Update flake.lock & generated files
body: |
## Flake lockfile
```
Expand All @@ -112,7 +102,7 @@ jobs:
echo "${pr} was ${operation}."
# markdown summary
echo "## ${{ matrix.branch }}" >> $GITHUB_STEP_SUMMARY
echo "## ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
echo "\`${head:0:6}\` pushed to \`${pr_branch}\`" >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
Expand Down

0 comments on commit 96dd414

Please sign in to comment.