name: SSH CI

on:
  push:
    branches: ["main"]
  # pull_request:
  #   branches: ["main"]

permissions:
  contents: read

jobs:
  ssh:
    if: github.repository == 'TecharoHQ/anubis'
    #runs-on: alrest-techarohq
    runs-on: ubuntu-latest
    strategy:
      matrix:
        host:
          - riscv64
          - ppc64le
          #- aarch64-4k
          #- aarch64-16k
    steps:
      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-tags: true
          fetch-depth: 0
          persist-credentials: false

      - name: Install CI target SSH key
        uses: shimataro/ssh-key-action@87a8f067114a8ce263df83e9ed5c849953548bc3 # v2.8.1
        with:
          key: ${{ secrets.CI_SSH_KEY }}
          name: id_rsa
          known_hosts: ${{ secrets.CI_SSH_KNOWN_HOSTS }}

      - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
        with:
          go-version: "stable"

      - name: Run CI
        run: go run ./utils/cmd/backoff-retry bash test/ssh-ci/rigging.sh ${{ matrix.host }}
        env:
          GITHUB_RUN_ID: ${{ github.run_id }}
