name: Deploy

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        run: actions/checkout@v3

      - name: Install Docker
        run: docker/setup-buildx-action@v2

      - name: Build Docker image
        run: docker build -t markdownblog .

      - name: Save Docker image as tarball
        run: docker save markdownblog -o markdownblog-image.tar

      - name: Upload Docker image artifact
        run: actions/upload-artifact@v3 --name markdownblog-docker-image --path markdownblog-image.tar

      - name: Push Docker image
        run: docker push 10.0.0.13:3002/rattatwinko/markdownblog:latest
