added step to deploy to docker swarm #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI/CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: self-hosted # Uses your self-hosted runner on the Swarm manager | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
run: docker build -t nettleship-net-api:latest -f server/Dockerfile server | |
- name: Deploy to Docker Swarm | |
run: | | |
# Make sure Docker is available and the image is built | |
docker pull nettleship-net-api:latest # (if needed, to ensure the latest is on the Pi) | |
# Deploy to Swarm | |
docker stack deploy -c docker-compose.yml nettleship-net-api |