From e470be243abc5219e5f9c748bcd3cfc7966f5fb1 Mon Sep 17 00:00:00 2001 From: Luke Channings <461449+LukeChannings@users.noreply.github.com> Date: Thu, 19 Sep 2024 14:10:38 +0000 Subject: [PATCH] Build dotfiles and sync to home branch --- .github/workflows/sync.yaml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/sync.yaml diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml new file mode 100644 index 0000000..046a63f --- /dev/null +++ b/.github/workflows/sync.yaml @@ -0,0 +1,54 @@ +name: "Sync Home Manager dotfiles to home branch" +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + outputs: + sha: ${{ steps.build.outputs.sha }} + steps: + - uses: "actions/checkout@v4" + - uses: "DeterminateSystems/nix-installer-action@main" + - uses: cachix/cachix-action@v14 + with: + name: luke-channings + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build packages + id: build + run: | + export NIXPKGS_ALLOW_UNFREE=1 + + nix run --accept-flake-config .#home-manager -- build --impure --flake .#luke + + mkdir home + rsync -aL --chown=$(whoami):$(whoami) --chmod=ug+rw result/home-files/.config/ home/ + cp -L result/home-files/.editorconfig home/ + cp -RL result/home-files/.ssh home/ssh + + echo "sha=$GITHUB_SHA" >> "$GITHUB_SHA" + - uses: actions/upload-artifact@v4 + with: + name: dotfiles + path: home + sync: + needs: [build] + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: home + - name: Download math result for job 1 + uses: actions/download-artifact@v4 + with: + name: dotfiles + - name: Push differences + run: | + git config --global user.name 'Luke Channings' + git config --global user.email 'lukechannings@users.noreply.github.com' + git commit -am "Sync ${{needs.build.outputs.sha}}" + git push