name: Publish to buf.build/didao/sonr
on:
  push:
    branches:
      - master
      - develop

permissions:
  contents: write
  issues: write

jobs:
  buf_push:
    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_pkl:
    runs-on: ubuntu-latest
    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: config/pkl
          destination-dir: .
