name: Build Docker Linux ARM64

on:
  push:
    branches:
      - main

jobs:
  build-docker-linux-arm64:
    runs-on: [self-hosted, linux, arm64, docker]
    steps:
      - name: Install packages
        run: apk add --no-cache git curl wget unzip bash nodejs npm docker

      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Get Repository Name
        id: get_repo
        run: |
          echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

      - name: Build Linux ARM64 Docker Image
        run: |
          docker build \
            -t gitea.penry.de/${{ env.REPO_LC }}:latest \
            .

      - name: Save Docker Image to Tar
        run: docker save -o CouchLog-Linux-ARM64-Docker-Image.tar gitea.penry.de/${{ env.REPO_LC }}:latest

      - name: Upload Artifact
        uses: actions/upload-artifact@v3
        with:
          name: CouchLog-Linux-ARM64-Docker-Image
          path: CouchLog-Linux-ARM64-Docker-Image.tar
          if-no-files-found: error
          retention-days: 5