hussh 0.2.3

Memory-safe SSH daemon for restricted TCP forwarding
name: Docker

on:
  push:
    branches: [ "main" ]
    tags: [ "v*.*.*" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-26.04
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false
      - uses: docker/setup-buildx-action@v3

      - name: Expose actions cache variables
        uses: actions/github-script@v6
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])

      - name: Build Docker image
        uses: docker/build-push-action@v5
        with:
          tags: hussh
          load: true
          cache-from: type=gha
          cache-to: type=gha,mode=max

      - name: Test the Docker image
        run: |
          docker run --rm hussh --help

      - name: Login to github container registry
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Push the image to `edge`
        if: github.event_name == 'push' && github.ref_name == 'main'
        run: |
          docker tag hussh ghcr.io/${{ github.repository }}:edge
          docker push ghcr.io/${{ github.repository }}:edge

      - name: Push the image to `${{ github.ref_name }}`
        if: github.ref_type == 'tag'
        run: |
          docker tag hussh ghcr.io/${{ github.repository }}:${{ github.ref_name }}
          docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}

      - name: Push the image to `latest`
        if: github.ref_type == 'tag'
        run: |
          docker tag hussh ghcr.io/${{ github.repository }}:latest
          docker push ghcr.io/${{ github.repository }}:latest