Test ansible scripts with Github workflows

This commit is contained in:
Tyler Starr 2022-12-29 23:49:46 -08:00
parent 4c3845f8d8
commit 961ae4abed
5 changed files with 68 additions and 11 deletions

17
.github/workflows/test.yaml vendored Normal file
View File

@ -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

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM ghcr.io/void-linux/void-linux:latest-full-x86_64
MAINTAINER starr-dusT <starrtyler88@gmail.com>
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"]

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: "3"
services:
dotfiles:
environment:
- CI=1
build: .
container_name: dotfiles
image: starr-dust/dotfiles
volumes:
- .:/usr/src/

14
docker-entrypoint.sh Executable file
View File

@ -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

View File

@ -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"