Skip to content

Commit

Permalink
Merge pull request #7 from jonathanchancey/docker-action
Browse files Browse the repository at this point in the history
add docker-action
  • Loading branch information
jonathanchancey authored Mar 10, 2024
2 parents 7de87c7 + 613ab04 commit 4a6334a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/scripts/prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# perform minimal preparation and run ansible
export DOTFILES_USER=$USER
echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$DOTFILES_USER > /dev/null
ansible-playbook $(git rev-parse --show-toplevel)/main.yml
20 changes: 20 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Docker Build Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-run:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t dotfiles .
- name: Run Docker container
run: docker run --rm dotfiles .github/scripts/prepare
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ COPY . $HOME/git/dotfiles
WORKDIR $HOME/git/dotfiles
USER root
RUN chown -R ansible-user:ansible-user $HOME

# add ansible user to sudoers file for pipelines
RUN echo "ansible-user ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/ansible-user > /dev/null

USER ansible-user
RUN echo /.dockerenv
RUN git config --global --add safe.directory '*'
# RUN git checkout eerie-fog
RUN chmod +x dotfiles.sh
RUN chmod +x .github/scripts/prepare

CMD $HOME/git/dotfiles/dotfiles.sh

0 comments on commit 4a6334a

Please sign in to comment.