DRF_Template/.woodpecker.yml

33 lines
1.1 KiB
YAML
Raw Normal View History

# .woodpecker.yml
steps:
2024-08-30 17:11:37 +08:00
- name: build-push
image: docker
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]
- name: update deployment and reset database
2024-08-30 17:11:37 +08:00
image: docker
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 '
cd "${PROJECT_DIR}";
docker-compose down;
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;
docker compose up -d'
2024-08-30 19:54:18 +08:00
secrets: [IMAGE_TAG, SSH_KEY, PROJECT_DIR]