34 lines
1.3 KiB
YAML
34 lines
1.3 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
name: Build & Deploy
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build and push Docker image
|
|
run: |
|
|
docker login gitlab.impresion3d.pro -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}"
|
|
docker build -t gitlab.impresion3d.pro/root/davidaragon-portfolio:latest .
|
|
docker push gitlab.impresion3d.pro/root/davidaragon-portfolio:latest
|
|
|
|
- name: Deploy to Portainer
|
|
run: |
|
|
# Stop stack
|
|
curl -X POST "${{ secrets.PORTAINER_URL }}/api/stacks/${{ secrets.PORTAINER_STACK_ID }}/stop?endpointId=${{ secrets.PORTAINER_ENDPOINT_ID }}" \
|
|
-H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}"
|
|
sleep 5
|
|
|
|
# Pull fresh image
|
|
curl -X POST "${{ secrets.PORTAINER_URL }}/api/endpoints/${{ secrets.PORTAINER_ENDPOINT_ID }}/docker/images/create?fromImage=gitlab.impresion3d.pro%2Froot%2Fdavidaragon-portfolio&tag=latest" \
|
|
-H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}"
|
|
|
|
# Start stack
|
|
curl -X POST "${{ secrets.PORTAINER_URL }}/api/stacks/${{ secrets.PORTAINER_STACK_ID }}/start?endpointId=${{ secrets.PORTAINER_ENDPOINT_ID }}" \
|
|
-H "X-API-Key: ${{ secrets.PORTAINER_TOKEN }}"
|