Skip to content

Commit

Permalink
Merge pull request #1 from pragmaticivan/ci-setup
Browse files Browse the repository at this point in the history
feat: init CI setup
  • Loading branch information
pragmaticivan authored Jul 4, 2024
2 parents b54bfed + aa868d5 commit 8d41e45
Show file tree
Hide file tree
Showing 17 changed files with 624 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
55 changes: 55 additions & 0 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: MacOS

on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "Makefile"
- "Dockerfile"
- "install/ubuntu/**"
- ".chezmoiscripts/ubuntu/**"
- "dot_tmux.conf.d/os/ubuntu.conf"
- "tests/install/ubuntu/**"

pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "Makefile"
- "Dockerfile"
- "install/ubuntu/**"
- ".chezmoiscripts/ubuntu/**"
- "dot_tmux.conf.d/os/ubuntu.conf"
- "tests/install/ubuntu/**"

jobs:
build:
runs-on: macos-14 # M1 Mac

steps:
- name: Setup dotfiles
env:
DOTFILES_DEBUG: 1
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "${EVENT_NAME}" == "push" ]; then
BRANCH_NAME="${{ github.ref_name }}"
elif [ "${EVENT_NAME}" == "pull_request" ]; then
BRANCH_NAME="${{ github.head_ref }}"
fi
export BRANCH_NAME
URL="https://raw.githubusercontent.com/pragmaticivan/dotfiles/${BRANCH_NAME}/setup.sh"
echo "Download setup.sh from ${URL}"
bash -c "$(curl -fsLS $URL)"
- name: Test file existence
run: |
brew install bats-core
cd $(chezmoi source-path)/../
bats --print-output-on-failure \
tests/files/common.bats \
tests/files/macos.bats
72 changes: 72 additions & 0 deletions .github/workflows/ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Ubuntu

on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "Makefile"
- "Dockerfile"
- "install/macos/**"
- ".chezmoiscripts/macos/**"
- "dot_tmux.conf.d/os/macos.conf"
- "tests/install/macos/**"

pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "Makefile"
- "Dockerfile"
- "install/macos/**"
- ".chezmoiscripts/macos/**"
- "dot_tmux.conf.d/os/macos.conf"

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
strategy:
matrix:
system: [server, client]

runs-on: ubuntu-latest
steps:
- name: Setup dotfiles
env:
SYSTEM: ${{ matrix.system }}
DOTFILES_DEBUG: 1
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "${EVENT_NAME}" == "push" ]; then
BRANCH_NAME="${{ github.ref_name }}"
elif [ "${EVENT_NAME}" == "pull_request" ]; then
BRANCH_NAME="${{ github.head_ref }}"
fi
export BRANCH_NAME
URL="https://raw.githubusercontent.com/pragmaticivan/dotfiles/${BRANCH_NAME}/setup.sh"
echo "Download setup.sh from ${URL}"
printf '${SYSTEM}\n' | bash -c "$(wget -qO - $URL)"
- name: Install latest bats-core
run: |
tmp_dir=$(mktemp -d /tmp/bats-core-XXXXX)
git clone --depth 1 https://github.com/bats-core/bats-core.git "${tmp_dir}"
cd "${tmp_dir}"
sudo ./install.sh /usr/local
rm -rf "${tmp_dir}"
- name: Test file existence
env:
SYSTEM: ${{ matrix.system }}
run: |
cd $(chezmoi source-path)/../
bats tests/files/common.bats
bats --filter-tags common,ubuntu:${SYSTEM} \
--print-output-on-failure \
tests/files/ubuntu.bats
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ubuntu:22.04

ARG USERNAME=shunk031
ARG USERNAME=pragmaticivan
ARG USER_UID=1000
ARG USER_GID=$USER_UID

ENV TZ=Asia/Tokyo
ENV TZ=America/Chicago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && \
Expand Down
File renamed without changes.
43 changes: 35 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
![dotfiles](https://github.com/pragmaticivan/dotfiles/assets/301291/291198e8-5175-4562-88a2-c885458cc003)


## Introduction
## 🚀 Overview

Your dotfiles are how you personalize your system. These are mine.

## Why

Maintaining dotfiles for your computer is crucial for several reasons. Firstly, it ensures consistency across different machines, allowing you to replicate your preferred settings, shortcuts, and configurations effortlessly. This consistency saves time and frustration when transitioning between workstations or setting up a new system. Secondly, dotfiles serve as a personal backup of your customized environment. By version-controlling them with tools like Git, you not only safeguard against accidental changes but also enable easy restoration in case of system crashes or upgrades.

## Install
## 🌴 Setup

To set up the dotfiles run the appropriate snippet in the terminal.

### 💻 `MacOS` [![MacOS](https://github.com/pragmaticivan/dotfiles/actions/workflows/macos.yaml/badge.svg)](https://github.com/pragmaticivan/dotfiles/actions/workflows/macos.yaml)

- Configuration snippet of the Apple Silicon MacOS environment for client macnine:

```console
bash -c "$(curl -fsLS https://raw.githubusercontent.com/pragmaticivan/dotfiles/main/setup.sh)"
```

### 🖥️ `Ubuntu` [![Ubuntu](https://github.com/pragmaticivan/dotfiles/actions/workflows/ubuntu.yaml/badge.svg)](https://github.com/pragmaticivan/dotfiles/actions/workflows/ubuntu.yaml)

- Configuration snippet of the Ubuntu environment for both client and server machine:

```console
bash -c "$(wget -qO - https://raw.githubusercontent.com/pragmaticivan/dotfiles/main/setup.sh)"
```

### Minimal setup

The following is a minimal setup command to install chezmoi and my dotfiles from the github repository on a new empty machine:

> sh -c "$(curl -fsLS get.chezmoi.io)" -- init pragmaticivan --apply

## 👏 Acknowledgements

Inspiration and code was taken from many sources, including:

1. `$ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply pragmaticivan`
- [shunk031/dotfiles](https://github.com/shunk031/dotfiles).
- [caarlos0/dotfiles](https://github.com/caarlos0/dotfiles).

## License
## 📝 License

MIT License
The code is available under the [MIT license](https://github.com/pragmaticivan/dotfiles/blob/master/LICENSE).
16 changes: 16 additions & 0 deletions home/.chezmoi.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- $system := "" -}}
{{- if hasKey . "system" -}}
{{- $system = .system -}}
{{- /* Set client to the MacOS default system */ -}}
{{- else if eq .chezmoi.os "darwin" -}}
{{ $system = "client" -}}
{{- else -}}
{{- $system = promptString "System (client or server)" -}}
{{- end -}}

data:
name: "Ivan Santos"
gitemail: "[email protected]"
system: {{ $system | quote }}
editor: "nvim"
visualeditor: "code"
4 changes: 0 additions & 4 deletions home/.chezmoidata.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions home/.chezmoiscripts/common/run_once_00-setup-ssh.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ if eq .chezmoi.os "linux" -}}
{{ if eq .chezmoi.osRelease.idLike "debian" -}}
{{ include "../install/ubuntu/common/ssh.sh" }}
{{ else -}}
echo "Invalid linux distribution: {{ .chezmoi.osRelease.id }}"
{{ end -}}
{{ end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ if eq .chezmoi.os "linux" -}}
{{ if eq .chezmoi.osRelease.idLike "debian" -}}
{{ include "../install/ubuntu/common/chezmoi.sh" }}
{{ end -}}
{{ end -}}
12 changes: 7 additions & 5 deletions home/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ cask "1password"
cask "netnewswire"
# cask "monodraw" - To evaluate
# cask "bartender" - To evaluate
mas "Affinity Photo 2: Image Editor", id: 1616822987
mas "Affinity Designer 2", id: 1616831348
mas "Amphetamine", id: 937984704
mas "Deliveries: a package tracker", id: 290986013
# mas "Affinity Photo 2: Image Editor", id: 1616822987
# mas "Affinity Designer 2", id: 1616831348
# mas "Amphetamine", id: 937984704
# mas "Deliveries: a package tracker", id: 290986013

# Entertainment Tools
cask "iina"
Expand Down Expand Up @@ -95,7 +95,9 @@ brew "bat"
brew "btop"
brew "gh"
brew "fd"
# brew "visidata"
brew "bats-core"
brew "chezmoi"
# brew "visidata" - To evaluate

# Cross-shell prompt

Expand Down
23 changes: 23 additions & 0 deletions install/ubuntu/common/chezmoi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -Eeuo pipefail

if [ "${DOTFILES_DEBUG:-}" ]; then
set -x
fi

function install_chezmoi() {
sudo sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin
}

function uninstall_chezmoi() {
sudo rm -fv /usr/local/bin/chezmoi
}

function main() {
install_chezmoi
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main
fi
27 changes: 27 additions & 0 deletions install/ubuntu/common/ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -Eeuo pipefail

if [ "${DOTFILES_DEBUG:-}" ]; then
set -x
fi

readonly PACKAGES=(
openssh-client
)

function install_openssh() {
sudo apt-get install -y "${PACKAGES[@]}"
}

function uninstall_openssh() {
sudo apt-get remove -y "${PACKAGES[@]}"
}

function main() {
install_openssh
}

if [ ${#BASH_SOURCE[@]} = 1 ]; then
main
fi
Loading

0 comments on commit 8d41e45

Please sign in to comment.