43 lines
1.1 KiB
YAML
43 lines
1.1 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Login to Registry (scoped)
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t fichajes .
|
|
|
|
- name: Tag Docker image
|
|
run: docker tag fichajes ${{ secrets.DOCKER_REGISTRY }}/hacecalor/fichajes:${{ github.run_number }}
|
|
|
|
- name: Push Docker image to registry
|
|
run: docker push ${{ secrets.DOCKER_REGISTRY }}/hacecalor/fichajes:${{ github.run_number }}
|
|
|
|
- name: Connect to remote host and deploy
|
|
uses: appleboy/ssh-action@v1
|
|
with:
|
|
host: ${{ secrets.REMOTE_HOST }}
|
|
username: ${{ secrets.REMOTE_USER }}
|
|
password: ${{ secrets.REMOTE_PASSWORD }}
|
|
script: |
|
|
docker pull
|
|
docker-compose up -d
|