initial commit

This commit is contained in:
BuckarooBanzay 2020-12-03 09:16:31 +01:00
commit 62e24fcffd
5 changed files with 85 additions and 0 deletions

18
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: docker
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: docker publish
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: buckaroobanzay/git_autoupdate
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tag_names: true
cache: true

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM alpine:3.12.1
# prepare minute job dir for crond
RUN mkdir /etc/periodic/minute
RUN echo "* * * * * run-parts /etc/periodic/minute" >> /etc/crontabs/root
# add deps
RUN apk add git
# add local files
COPY ./entrypoint.sh /entrypoint.sh
COPY ./jobs/update.sh /etc/periodic/minute/update
CMD ["/entrypoint.sh"]

12
entrypoint.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
crond -f &
crond_pid=$!
while `true`
do
sleep 3600
done
# kill $crond_pid

15
jobs/update.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/sh
test -d "$GIT_DIR" || exit
cd $GIT_DIR
test -z "$GIT_BRANCH" && GIT_BRANCH=master
git remote update
git diff --exit-code HEAD origin/$GIT_BRANCH && exit
echo "updating repository"
# pull branch
git pull origin $GIT_BRANCH
echo "Update complete!"

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
git repository auto updater
------------
# Overview
Auto-updates a git repository
# Environment variables
* **GIT_DIR** path to the git repo
* **GIT_BRANCH** branch to use (optional)
# Usage
```bash
docker run \
-v /my/git/repo:/git \
-e GIT_DIR=/git \
-e GIT_BRANCH=master \
buckaroobanzay/git_autoupdate
```
# License
MIT