49 lines
1.2 KiB
YAML
49 lines
1.2 KiB
YAML
name: Build and deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
push: true
|
|
tags: smallbuster/fe-docs:latest
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Compose
|
|
run: |
|
|
docker compose version
|
|
|
|
- name: Stop and remove existing containers
|
|
run: |
|
|
docker compose -f docker-compose.yaml down || true
|
|
|
|
- name: Pull Docker images
|
|
run: |
|
|
docker compose -f docker-compose.yaml pull
|
|
|
|
- name: Start containers
|
|
run: |
|
|
docker compose -f docker-compose.yaml up -d |