2024-08-30 16:52:15 +08:00
|
|
|
# .woodpecker.yml
|
|
|
|
steps:
|
2024-08-30 17:11:37 +08:00
|
|
|
- name: build-push
|
|
|
|
image: docker
|
2024-08-30 16:52:15 +08:00
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
- event: push
|
|
|
|
commands:
|
2024-08-30 19:54:18 +08:00
|
|
|
- docker build . -t "$IMAGE_TAG"
|
|
|
|
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --password-stdin -u "$REGISTRY_USERNAME"
|
|
|
|
- docker push "$IMAGE_TAG"
|
2024-08-30 17:11:37 +08:00
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
2024-08-30 19:54:18 +08:00
|
|
|
secrets: [IMAGE_TAG, REGISTRY, REGISTRY_USERNAME, REGISTRY_PASSWORD]
|
2024-08-30 16:52:15 +08:00
|
|
|
- name: update deployment and reset database
|
2024-08-30 17:11:37 +08:00
|
|
|
image: docker
|
2024-08-30 16:52:15 +08:00
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
- event: push
|
|
|
|
commands:
|
|
|
|
- mkdir -p /root/.ssh/
|
|
|
|
- echo "$SSH_KEY" | tr -d '\r' > /root/.ssh/id_rsa
|
|
|
|
- chmod 600 /root/.ssh/id_rsa
|
|
|
|
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config
|
|
|
|
- ssh root@10.0.10.4 '
|
2024-08-30 19:28:24 +08:00
|
|
|
cd $PROJECT_DIR;
|
2024-08-30 16:52:15 +08:00
|
|
|
docker-compose down;
|
2024-08-30 19:54:18 +08:00
|
|
|
docker image rm "$IMAGE_TAG" || true;
|
|
|
|
docker pull "$IMAGE_TAG":latest;
|
2024-08-30 20:10:17 +08:00
|
|
|
docker volume rm "${IMAGE_TAG}_db_data" || true;
|
2024-08-30 16:52:15 +08:00
|
|
|
docker compose up -d'
|
2024-08-30 19:54:18 +08:00
|
|
|
secrets: [IMAGE_TAG, SSH_KEY, PROJECT_DIR]
|