-
Hello all, after setting up chezmoi for all the different devices I use, I'm convinced I'll stay with it for the coming future. These config files contain not only my theme for my Linux desktop, but also some (not secret, but theme-unrelated) configs for servers and work devices. I would like to share my desktop theme, based on these files, but not the entire repo with all that unrelated content. I was thinking that something like this should be achievable with GitHub workflows. Sadly, I'm very unfamiliar with writing those, so I wanted to reach out and ask for community input on how to write this. The flow I was imagining goes like this:
Again, in my head this doesn't sound hard to achieve, but I've been reading the GitHub Workflow documentation for a while now without getting anywhere. If anyone would have some helpful input, I'd greatly appreciate it! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I've played around with this a bit more and managed to come up with a fully working solution, checking all the boxes. Should anyone come across this, admittedly edgecase, scenario, I'll publish my solution here: The workflow file, placed in name: Publish theme to public repo
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: 'repo'
- name: Build dotfiles
run: sh repo/.build/build.sh
- name: Push to public repo
uses: cpina/[email protected]
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: 'output'
destination-github-username: 'justrainer' # replace this with your github username
destination-repository-name: 'pretty_dotfiles' # replace this with your target repo name
commit-message: 'Updated from private repo'
target-directory: 'dotfiles' It requires the setup from the "Push to another repo" documentation, as this requires SSH keys. The docs can be found here. The build script being run by the GitHub action should be placed in the folder #! /bin/bash
echo "Current work directory: $(pwd)"
echo "Installing chezmoi"
sh -c "$(curl -fsLS get.chezmoi.io)"
echo "Applying custom chezmoiignore"
cat repo/.build/.chezmoiignore > repo/.chezmoiignore
echo "Building dotfiles"
echo "----"
echo "BUILDING:"
./bin/chezmoi -S repo/ managed
echo "IGNORING:"
./bin/chezmoi -S repo/ ignored
echo "----"
mkdir -p output/.config
./bin/chezmoi -S repo/ -D output/ -k --force apply
echo "Done." Pushing these three files to your main online repo is all you need to do (other than creating your public repo of course). On every push to the private repo, your desired files will be pushed to your public repo into the I somewhat doubt anyone will come across this or even find it useful. But in the rare case that someone found it helpful or interesting, I thought I'd share the solution. |
Beta Was this translation helpful? Give feedback.
-
I really love learning how others deal with niche situations like this. If I understood correctly, it seems you've gone with a triggered push approach to share dotifles Is this what is happening here? (you can use mermaid to draw) sequenceDiagram
actor User
User->>+Private: push update
Private->>+GitHubWorkflow: trigger
GitHubWorkflow->>Public: push public stuff
GitHubWorkflow-->>-Private:
Private-->>-User: done
Are there any other ways you'you thought about solving this issue and ruled out? |
Beta Was this translation helpful? Give feedback.
-
Late to the party, but I've just got this running. Latest build, tested on ubuntu and macOS: https://github.com/twitchel/dotfiles/actions/runs/9882522359 |
Beta Was this translation helpful? Give feedback.
I've played around with this a bit more and managed to come up with a fully working solution, checking all the boxes. Should anyone come across this, admittedly edgecase, scenario, I'll publish my solution here:
The workflow file, placed in
.github/workflows/
on your chezmoi repo, looks like this: