diff --git a/.github/workflows/sync-main.yml b/.github/workflows/sync-main.yml index d92f97f..8b95eba 100644 --- a/.github/workflows/sync-main.yml +++ b/.github/workflows/sync-main.yml @@ -2,11 +2,18 @@ name: Sync branches into main on: schedule: - - cron: "0 14 * * 1" - - - cron: "0 14 * * 3" + - cron: "0 14 * * 1" # Monday + - cron: "0 14 * * 3" # Wednesday workflow_dispatch: + inputs: + source: + description: Branch to sync into main + required: true + type: choice + options: + - laptop + - desktop permissions: contents: write @@ -17,42 +24,82 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Determine source branch id: branch run: | - DOW=$(date -u +%u) - - if [ "$DOW" = "1" ]; then - echo "source=laptop" >> "$GITHUB_OUTPUT" - elif [ "$DOW" = "3" ]; then - echo "source=desktop" >> "$GITHUB_OUTPUT" - else - echo "Not a scheduled sync day" - exit 1 + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "source=${{ inputs.source }}" >> "$GITHUB_OUTPUT" + exit 0 fi - - name: Create pull request - id: cpr - uses: peter-evans/create-pull-request@v7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - base: main - branch: ${{ steps.branch.outputs.source }} - title: "Weekly sync: ${{ steps.branch.outputs.source }} → main" - body: | - This pull request was created automatically by GitHub Actions. + DOW=$(date -u +%u) - If the branch can be merged cleanly, auto-merge will merge it automatically. + case "$DOW" in + 1) + echo "source=laptop" >> "$GITHUB_OUTPUT" + ;; + 3) + echo "source=desktop" >> "$GITHUB_OUTPUT" + ;; + *) + echo "No sync scheduled today." + exit 1 + ;; + esac - If there are merge conflicts, this PR will remain open until they are resolved. - draft: false + - name: Check for existing PR + id: existing + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=$(gh pr list \ + --base main \ + --head "${{ steps.branch.outputs.source }}" \ + --state open \ + --json number \ + --jq '.[0].number // empty') + + echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + + - name: Create PR + id: create + if: steps.existing.outputs.number == '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base main \ + --head "${{ steps.branch.outputs.source }}" \ + --title "Weekly sync: ${{ steps.branch.outputs.source }} → main" \ + --body "This pull request was created automatically by GitHub Actions." + + PR_NUMBER=$(gh pr list \ + --base main \ + --head "${{ steps.branch.outputs.source }}" \ + --state open \ + --json number \ + --jq '.[0].number') + + echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + + - name: Determine PR number + id: pr + run: | + if [ -n "${{ steps.existing.outputs.number }}" ]; then + echo "number=${{ steps.existing.outputs.number }}" >> "$GITHUB_OUTPUT" + else + echo "number=${{ steps.create.outputs.number }}" >> "$GITHUB_OUTPUT" + fi - name: Enable auto-merge - if: steps.cpr.outputs.pull-request-number + if: steps.pr.outputs.number != '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr merge \ - ${{ steps.cpr.outputs.pull-request-number }} \ + "${{ steps.pr.outputs.number }}" \ --auto \ --merge diff --git a/flake.lock b/flake.lock index 0cd8243..2df4118 100644 --- a/flake.lock +++ b/flake.lock @@ -34,11 +34,11 @@ "quickshell": "quickshell" }, "locked": { - "lastModified": 1780907625, - "narHash": "sha256-YH1LHLhoAlSmXmVz9qhY+QLFWbLVFJWSaPJ3ORr5grQ=", + "lastModified": 1780996864, + "narHash": "sha256-OIDk3FiSKjYLV4Dvfv6fMeVcV3Dk9+MBBKTORNqMsUg=", "owner": "caelestia-dots", "repo": "shell", - "rev": "66a9f2f220a9cc6a29ce4b66691f0117bdd35704", + "rev": "c46593d438a75fce42f28529662b678b79d94693", "type": "github" }, "original": { @@ -212,11 +212,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1780928217, - "narHash": "sha256-Cvq31DIGCKet/UFsJd20YIwCoZmX91xQBV5oiR1bU1k=", + "lastModified": 1780997039, + "narHash": "sha256-8pPXOCZkrySE3zwtix2MYxm9NzzHT/XQr0mHJsf3lis=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2ef2f7e4a2999ffaab2ac987e69f5f8e29ec73cf", + "rev": "872eb0174d0d5a1bc37388ff84eea2bca44b1065", "type": "github" }, "original": { @@ -251,11 +251,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1780747962, - "narHash": "sha256-IX7G1dlKrOqPOImfbo7ADDfV5yU1+j+MRChI3TL4tAA=", + "lastModified": 1780930886, + "narHash": "sha256-rppURzHviaQN131F+nLiLdGfcb0uCd9gGP0E5+iw9MI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cbb5cf358f50aa6acc9efd6113b7bcfbc352cd73", + "rev": "8c3cede7ddc26bd659d2d383b5610efbd2c7a16e", "type": "github" }, "original": { @@ -265,6 +265,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1780902259, + "narHash": "sha256-q8yYEC5f1mFlQO9RGna4LTc9QrcvWunX6FYp83munkQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bd0ff2d3eac24699c3664d5966b9ef36f388e2ca", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, "notewrapper": { "inputs": { "flake-utils": [ diff --git a/modules/utilities/nixGitCherryPicker.nix b/modules/utilities/nixGitCherryPicker.nix index 37868a5..8b13c75 100644 --- a/modules/utilities/nixGitCherryPicker.nix +++ b/modules/utilities/nixGitCherryPicker.nix @@ -1,5 +1,25 @@ {inputs, ...}: { +<<<<<<< desktop + flake.homeModules.nix-git-cherry-picker-laptop = {pkgs, ...}: { + home.packages = [ + inputs.nix-git-cherry-picker.packages.${pkgs.system}.default + ]; + home.file.".config/nix-git-cherry-picker/config.json" = { + enable = true; + text = '' + { + "localBranch": "laptop", + "remoteBranch": "desktop", + "nixConfigPath": "/home/tomasr/nixos/" + } + ''; + force = true; + }; + }; + flake.homeModules.nix-git-cherry-picker-desktop = {pkgs, ...}: { +======= flake.homeModules.nixGitCherryPicker-laptop = {pkgs, ...}: { +>>>>>>> main home.packages = [ inputs.nix-git-cherry-picker.packages.${pkgs.system}.default ];