initial commit
This commit is contained in:
commit
62e24fcffd
18
.github/workflows/docker.yml
vendored
Normal file
18
.github/workflows/docker.yml
vendored
Normal 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
14
Dockerfile
Normal 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
12
entrypoint.sh
Normal 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
15
jobs/update.sh
Normal 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
26
readme.md
Normal 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
|
Loading…
x
Reference in New Issue
Block a user