This commit is contained in:
parent
a01c098075
commit
712ddb76ca
72
.drone.yml
72
.drone.yml
@ -30,16 +30,33 @@ steps:
|
|||||||
- COMMIT_HASH=$(git log -n 1 --pretty=%H)
|
- COMMIT_HASH=$(git log -n 1 --pretty=%H)
|
||||||
# collect info from current image
|
# collect info from current image
|
||||||
- echo $REGISTRY_PWD | docker login -u drone --password-stdin registry.jfmonty2.com
|
- echo $REGISTRY_PWD | docker login -u drone --password-stdin registry.jfmonty2.com
|
||||||
- docker pull registry.jfmonty2.com/drone-server:latest
|
# defaults to 0 if image can't be found
|
||||||
- IMAGE_COMMIT_HASH=$(docker image inspect -f '{{ .Config.Labels.drone_commit_hash }}' registry.jfmonty2.com/drone-server:latest)
|
- docker pull registry.jfmonty2.com/drone-server:latest || true
|
||||||
# compare and trigger CI if necessary
|
- IMAGE_COMMIT_HASH=$(docker image inspect -f '{{ .Config.Labels.drone_commit_hash }}' registry.jfmonty2.com/drone-server:latest || echo 0)
|
||||||
|
# compare and trigger build if necessary
|
||||||
- |
|
- |
|
||||||
if [[ $COMMIT_HASH != $IMAGE_COMMIT_HASH ]]; then
|
if [[ $COMMIT_HASH != $IMAGE_COMMIT_HASH ]]; then
|
||||||
echo 'Updates available, triggering server build.'
|
echo 'Updates available, triggering server build.'
|
||||||
curl -X POST -H "Authorization: Bearer $DRONE_API_TOKEN" \
|
curl -X POST -H "Authorization: Bearer $DRONE_API_TOKEN" \
|
||||||
https://drone.jfmonty2.com/api/repos/jfmonty2/drone/builds/$DRONE_BUILD_NUMBER/promote?target=server-build
|
https://drone.jfmonty2.com/api/repos/jfmonty2/drone/builds/$DRONE_BUILD_NUMBER/promote?target=server-build
|
||||||
else
|
else
|
||||||
echo 'Image is already up to date.'
|
echo 'Server is already up to date.'
|
||||||
|
fi
|
||||||
|
# now check for runner
|
||||||
|
- echo "Checking for new runner version"
|
||||||
|
- RELEASE=$(curl https://api.github.com/repos/drone-runners/drone-runner-exec/releases | jq -r '.[0]')
|
||||||
|
- LATEST_VERSION=$(echo $RELEASE | jq -r '.tag_name')
|
||||||
|
# get version of currently running instance (also defaults to 0 if not found)
|
||||||
|
- docker pull registry.jfmonty2.com/drone-runner-exec:latest || true
|
||||||
|
- CURRENT_VERSION=$(docker image inspect -f '{{ .Config.Labels.drone_runner_version }}' registry.jfmonty2.com/drone-runner-exec:latest || echo 0)
|
||||||
|
# compare and trigger build if necessary
|
||||||
|
- |
|
||||||
|
if [[ $LATEST_VERSION != $CURRENT_VERSION ]]; then
|
||||||
|
echo 'New release available, triggering runner build.'
|
||||||
|
curl -X POST -H "Authorization: Bearer $DRONE_API_TOKEN" \
|
||||||
|
https://drone.jfmonty2.com/api/repos/jfmonty2/drone/builds/$DRONE_BUILD_NUMBER/promote?target=runner-build
|
||||||
|
else
|
||||||
|
echo 'Runner is already up to date.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
@ -120,9 +137,54 @@ steps:
|
|||||||
- echo $REGISTRY_PWD | docker login -u drone --password-stdin registry.jfmonty2.com
|
- echo $REGISTRY_PWD | docker login -u drone --password-stdin registry.jfmonty2.com
|
||||||
- docker push registry.jfmonty2.com/drone-server:latest
|
- docker push registry.jfmonty2.com/drone-server:latest
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: docker-socket
|
- name: docker-socket
|
||||||
host:
|
host:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: runner-exec
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- promote
|
||||||
|
target:
|
||||||
|
- runner-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker-build
|
||||||
|
image: docker:latest
|
||||||
|
volumes:
|
||||||
|
- name: docker-socket
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
# get version number
|
||||||
|
- apk add curl jq
|
||||||
|
- RUNNER_VERSION=$(curl https://api.github.com/repos/drone-runners/drone-runner-exec/releases | jq -r '.[0].tag_name')
|
||||||
|
# get the binary
|
||||||
|
- cd runner-exec
|
||||||
|
- curl -L https://github.com/drone-runners/drone-runner-exec/releases/latest/download/drone_runner_exec_linux_amd64.tar.gz | tar xz
|
||||||
|
- >
|
||||||
|
docker build
|
||||||
|
-t registry.jfmonty2.com/drone-runner-exec:latest
|
||||||
|
--label drone_runner_version=$RUNNER_VERSION
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: deploy
|
||||||
|
image: docker:latest
|
||||||
|
volumes:
|
||||||
|
- name: docker-socket
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
environment:
|
||||||
|
REGISTRY_PWD:
|
||||||
|
from_secret: registry_pwd
|
||||||
|
commands:
|
||||||
|
- echo $REGISTRY_PWD | docker login -u drone --password-stdin registry.jfmonty2.com
|
||||||
|
- docker push registry.jfmonty2.com/drone-runner-exec:latest
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: docker-socket
|
||||||
|
host:
|
||||||
|
path: /var/run/docker.sock
|
9
runner-exec/Dockerfile
Normal file
9
runner-exec/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
|
||||||
|
RUN apk update --no-cache
|
||||||
|
RUN apk add --no-cache git curl jq yq python3 docker-cli
|
||||||
|
RUN ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
|
COPY ./drone-runner-exec /bin/
|
||||||
|
CMD ["drone-runner-exec"]
|
Loading…
x
Reference in New Issue
Block a user