name: Regenerate ssh ci runner image

on:
  # pull_request:
  #   branches: ["main"]
  schedule:
    - cron: "0 0 1,8,15,22 * *"
  workflow_dispatch:

permissions:
  pull-requests: write
  contents: write
  packages: write

jobs:
  ssh-ci-rebuild:
    if: github.repository == 'TecharoHQ/anubis'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-tags: true
          fetch-depth: 0
          persist-credentials: false
      - name: Log into registry
        uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
      - name: Build and push
        run: |
          cd ./test/ssh-ci
          docker buildx bake --push
