From 961ae4abed964fbacd2405c73b8e078611a1f5b0 Mon Sep 17 00:00:00 2001 From: starr-dusT Date: Thu, 29 Dec 2022 23:49:46 -0800 Subject: [PATCH] Test ansible scripts with Github workflows --- .github/workflows/test.yaml | 17 +++++++++++++++ Dockerfile | 23 +++++++++++++++++++++ docker-compose.yml | 10 +++++++++ docker-entrypoint.sh | 14 +++++++++++++ home/bin/executable_void-initial-setup.tmpl | 15 ++++---------- 5 files changed, 68 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/test.yaml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 docker-entrypoint.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..3cc9a200 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,17 @@ +name: dotfiles +on: push + +jobs: + void: + runs-on: ubuntu-latest + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - name: Pull docker image + run: docker-compose pull + + - name: Run installer on Void + run: docker-compose up --build --exit-code-from dotfiles diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bbb2eb62 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/void-linux/void-linux:latest-full-x86_64 +MAINTAINER starr-dusT + +RUN xbps-install -Su xbps -y +RUN xbps-install -S sudo bash -y + +RUN useradd -ms /bin/bash tstarr +RUN gpasswd -a tstarr wheel +RUN echo 'tstarr ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf +RUN echo "en_US.UTF-8 UTF-8" > /etc/default/libc-locales +RUN xbps-reconfigure -f glibc-locales + +USER tstarr + +RUN mkdir -p /home/tstarr/.local/share/chezmoi +COPY --chown=tstarr:users . ./home/tstarr/.local/share/chezmoi +WORKDIR /home/tstarr/.local/share/chezmoi + +RUN locale + +ENTRYPOINT ["sh", "docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..afc2ffec --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3" +services: + dotfiles: + environment: + - CI=1 + build: . + container_name: dotfiles + image: starr-dust/dotfiles + volumes: + - .:/usr/src/ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..b479bb41 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# This script stands in for the void-initial scripts that bootstraps void with +# some specific fixes to work within github workflows + +# Install seed packages +whoami +sudo xpbs-install -Syu -y +sudo xbps-install python3 python3-pip ansible -y +sudo pip install pexpect github3.py + +# Install roles and run playbook +LANG=en_US.UTF-8 ansible-galaxy install -r /home/tstarr/.local/share/chezmoi/provision/requirements.yml +cd /home/tstarr/.local/share/chezmoi/provision +LANG=en_US.UTF-8 ansible-playbook setup.yml -i hosts diff --git a/home/bin/executable_void-initial-setup.tmpl b/home/bin/executable_void-initial-setup.tmpl index 45c8a50d..e8d68254 100644 --- a/home/bin/executable_void-initial-setup.tmpl +++ b/home/bin/executable_void-initial-setup.tmpl @@ -3,9 +3,9 @@ echo -e "Starting initial setup..." # Install ansible python dependencies -sudo xpbs-install -Syu -sudo xbps-install python3 python3-pip ansible -sudo pip install pexpect github3.py +sudo xpbs-install -Syu -y +sudo xbps-install python3 python3-pip ansible -y +sudo pip install pexpect github3.py -y # Install ansible extensions ansible-galaxy install -r {{ .chezmoi.workingTree }}/provision/requirements.yml @@ -17,11 +17,4 @@ ansible-playbook setup.yml -i hosts --ask-become-pass # Return to where you were cd - -read -p "Reboot? " -n 1 -r -echo # (optional) move to a new line -if [[ ! $REPLY =~ ^[Yy]$ ]] -then - exit 0 -fi - -sudo reboot +echo "I'd suggest rebooting"