2024-09-01 19:36:33 +08:00
|
|
|
# .woodpecker.yml
|
|
|
|
steps:
|
|
|
|
- name: build
|
|
|
|
image: docker
|
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
event: push
|
|
|
|
commands:
|
2024-09-05 20:36:31 +08:00
|
|
|
- docker build --platform linux/arm64 --no-cache -t "$IMAGE" .
|
|
|
|
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --password-stdin -u "$REGISTRY_USERNAME"
|
|
|
|
- docker push "$IMAGE"
|
2024-09-01 19:36:33 +08:00
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
2024-09-05 20:36:31 +08:00
|
|
|
secrets: [REGISTRY, REGISTRY_USERNAME, REGISTRY_PASSWORD, IMAGE]
|
2024-09-01 19:36:33 +08:00
|
|
|
- name: deploy
|
|
|
|
image: docker
|
|
|
|
when:
|
|
|
|
- branch: master
|
|
|
|
event: push
|
|
|
|
commands:
|
2024-09-05 14:09:25 +08:00
|
|
|
- mkdir -p /root/.ssh/
|
2024-09-01 19:36:33 +08:00
|
|
|
- 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
|
2024-09-05 20:36:31 +08:00
|
|
|
- ssh "$REMOTE_HOST" "
|
|
|
|
cd $PROJECT_DIRECTORY;
|
2024-09-01 19:36:33 +08:00
|
|
|
docker-compose -f docker-compose.demo.yml down;
|
2024-09-05 20:36:31 +08:00
|
|
|
docker image rm "$IMAGE" || true;
|
|
|
|
docker volume rm "$VOLUME" || true;
|
|
|
|
docker pull "$IMAGE";
|
2024-09-07 13:51:26 +08:00
|
|
|
docker compose -f docker-compose.demo.yml up -d;
|
|
|
|
docker image prune -af;"
|
2024-09-05 20:36:31 +08:00
|
|
|
secrets: [SSH_KEY, REMOTE_HOST, PROJECT_DIRECTORY, IMAGE, VOLUME]
|