del workflow
This commit is contained in:
61
.github/workflows/ci.yml
vendored
61
.github/workflows/ci.yml
vendored
@@ -1,61 +0,0 @@
|
|||||||
name: Deploy to Docker Swarm (Worker Node)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
run: |
|
|
||||||
docker build -t ghcr.io/serverussnap/imagegenerator:latest .
|
|
||||||
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u serverussnap --password-stdin
|
|
||||||
docker push ghcr.io/serverussnap/imagegenerator:latest
|
|
||||||
|
|
||||||
- name: Add SSH key to known_hosts
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts
|
|
||||||
|
|
||||||
- name: Setup SSH key
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "${{ secrets.VM_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
||||||
chmod 600 ~/.ssh/id_rsa
|
|
||||||
|
|
||||||
- name: Test SSH connection
|
|
||||||
run: |
|
|
||||||
ssh -v -i ~/.ssh/id_rsa ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }} "echo 'SSH Connection successful!'"
|
|
||||||
|
|
||||||
- name: Deploy to Swarm Worker Node
|
|
||||||
uses: appleboy/ssh-action@v1.0.0
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.VM_HOST }}
|
|
||||||
username: ${{ secrets.VM_USER }}
|
|
||||||
key: ${{ secrets.VM_SSH_KEY }}
|
|
||||||
script: |
|
|
||||||
docker login ghcr.io -u serverussnap -p ${{ secrets.GHCR_TOKEN }}
|
|
||||||
|
|
||||||
if docker service inspect imagegenerator_service >/dev/null 2>&1; then
|
|
||||||
docker service update \
|
|
||||||
--image ghcr.io/serverussnap/imagegenerator:latest \
|
|
||||||
--publish-add 3050:3000 \
|
|
||||||
--constraint node.hostname==worker \
|
|
||||||
--with-registry-auth \
|
|
||||||
imagegenerator_service
|
|
||||||
else
|
|
||||||
docker service create \
|
|
||||||
--name imagegenerator_service \
|
|
||||||
--publish 3050:3000 \
|
|
||||||
--constraint node.hostname==worker \
|
|
||||||
--with-registry-auth \
|
|
||||||
ghcr.io/serverussnap/imagegenerator:latest
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker image prune -a -f
|
|
||||||
Reference in New Issue
Block a user