mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
33 lines
1.1 KiB
YAML
33 lines
1.1 KiB
YAML
# .woodpecker.yml
|
|
steps:
|
|
- name: build
|
|
image: docker
|
|
when:
|
|
- branch: master
|
|
event: push
|
|
commands:
|
|
- docker build --platform linux/arm64 --no-cache -t "$IMAGE" .
|
|
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --password-stdin -u "$REGISTRY_USERNAME"
|
|
- docker push "$IMAGE"
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
secrets: [REGISTRY, REGISTRY_USERNAME, REGISTRY_PASSWORD, IMAGE]
|
|
- name: deploy
|
|
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 "$REMOTE_HOST" "
|
|
cd $PROJECT_DIRECTORY;
|
|
docker-compose -f docker-compose.demo.yml down;
|
|
docker image rm "$IMAGE" || true;
|
|
docker volume rm "$VOLUME" || true;
|
|
docker pull "$IMAGE";
|
|
docker compose -f docker-compose.demo.yml up -d;
|
|
docker image prune -af;"
|
|
secrets: [SSH_KEY, REMOTE_HOST, PROJECT_DIRECTORY, IMAGE, VOLUME]
|