name: Upload Public Assets
on:
  push:
    branches:
      - develop

permissions:
  contents: write
  issues: write

jobs:
  buf_push:
    name: Publish to buf.build/onsonr/sonr
    runs-on: ubuntu-latest
    steps:
      # Run `git checkout`
      - uses: actions/checkout@v3
      # Install the `buf` CLI
      - uses: bufbuild/buf-setup-action@v1
      # Push only the Input in `proto` to the BSR
      - uses: bufbuild/buf-push-action@v1
        continue-on-error: true
        with:
          input: proto
          buf_token: ${{ secrets.BUF_TOKEN }}

  #
  # upload_configs:
  #   runs-on: ubuntu-latest
  #   name: Publish to configs.sonr.id
  #   steps:
  #     - name: checkout
  #       uses: actions/checkout@v4
  #     - name: Upload to R2
  #       continue-on-error: true
  #       uses: ryand56/r2-upload-action@latest
  #       with:
  #         r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
  #         r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
  #         r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
  #         r2-bucket: configs
  #         source-dir: config
  #         destination-dir: ./pkl
  #

  upload_pkl:
    runs-on: ubuntu-latest
    name: Publish to pkl.sh
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - name: Upload to R2
        uses: ryand56/r2-upload-action@latest
        with:
          r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
          r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
          r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
          r2-bucket: pkljar
          source-dir: pkl
          destination-dir: .

  upload_nebula_cdn:
    runs-on: ubuntu-latest
    name: Publish to cdn.sonr.id
    steps:
      - name: checkout
        uses: actions/checkout@v4
      - name: Upload to R2
        uses: ryand56/r2-upload-action@latest
        with:
          r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
          r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
          r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
          r2-bucket: nebula
          source-dir: pkg/nebula/assets
          destination-dir: .
