feat: add pipeline v4
This commit is contained in:
parent
65106dea82
commit
c10d0c7474
@ -1,10 +1,11 @@
|
|||||||
# .woodpecker.yml
|
# .woodpecker.yml
|
||||||
|
# -----------------
|
||||||
|
# Build, publish, and deploy Python app
|
||||||
|
|
||||||
when:
|
when:
|
||||||
event: [ push, pull_request ]
|
event: [ push ]
|
||||||
branch: [ main, develop, feat/*, feature/* ]
|
branch: [ main ]
|
||||||
|
|
||||||
# Pipeline steps
|
|
||||||
steps:
|
steps:
|
||||||
- name: publish-image
|
- name: publish-image
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
@ -20,37 +21,34 @@ steps:
|
|||||||
- latest
|
- latest
|
||||||
- ${CI_COMMIT_SHA}
|
- ${CI_COMMIT_SHA}
|
||||||
when:
|
when:
|
||||||
event: [ push, pull_request ]
|
event: [ push ]
|
||||||
|
branch: [ main ]
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
|
depends_on: [ publish-image ]
|
||||||
image: alpine:3.20
|
image: alpine:3.20
|
||||||
environment:
|
environment:
|
||||||
DEPLOY_USER: rov
|
DEPLOY_USER: rov
|
||||||
DEPLOY_HOST: mangamochi.badger-pirarucu.ts.net
|
DEPLOY_HOST: mangamochi.badger-pirarucu.ts.net
|
||||||
DEPLOY_PORT: 22
|
DEPLOY_PORT: 22
|
||||||
IMAGE: git.badger-pirarucu.ts.net/mangamochi/manga-matcher:${CI_COMMIT_SHA}
|
IMAGE: git.badger-pirarucu.ts.net/mangamochi/manga-matcher:${CI_COMMIT_SHA}
|
||||||
secrets: [ DEPLOY_SSH_KEY ]
|
DEPLOY_SSH_KEY:
|
||||||
|
from_secret: DEPLOY_SSH_KEY
|
||||||
commands:
|
commands:
|
||||||
- echo "🚀 Deploying to $DEPLOY_HOST ..."
|
- echo "🚀 Deploying to $DEPLOY_HOST ..."
|
||||||
- apk add --no-cache openssh-client docker-cli
|
- apk add --no-cache openssh-client docker-cli
|
||||||
# Setup SSH key
|
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
- echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_rsa
|
- echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_rsa
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
# Add host to known_hosts to prevent prompt
|
|
||||||
- ssh-keyscan -p $DEPLOY_PORT $DEPLOY_HOST >> ~/.ssh/known_hosts
|
- ssh-keyscan -p $DEPLOY_PORT $DEPLOY_HOST >> ~/.ssh/known_hosts
|
||||||
# Run deployment commands remotely
|
|
||||||
- >
|
- >
|
||||||
ssh -p $DEPLOY_PORT $DEPLOY_USER@$DEPLOY_HOST "
|
ssh -p $DEPLOY_PORT $DEPLOY_USER@$DEPLOY_HOST "
|
||||||
docker pull $IMAGE &&
|
docker pull $IMAGE &&
|
||||||
docker stop manga-matcher || true &&
|
docker stop manga-matcher 2>/dev/null || true &&
|
||||||
docker rm manga-matcher || true &&
|
docker rm manga-matcher 2>/dev/null || true &&
|
||||||
docker run -d
|
docker run -d --name manga-matcher --restart always -p 8000:8000 $IMAGE
|
||||||
--name manga-matcher
|
|
||||||
--restart always
|
|
||||||
-p 8000:8000
|
|
||||||
$IMAGE
|
|
||||||
"
|
"
|
||||||
when:
|
when:
|
||||||
event: [ push, pull_request ]
|
event: [ push ]
|
||||||
|
branch: [ main ]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user