---
name: "🔄 Rclone"
on:
  push:
    branches: [main]
    paths:
      - "lib/**"
      - ".github/workflows/rclone-action.yml"
  workflow_dispatch: {}

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  sync:
    if: github.repository == 'z-shell/src'
    runs-on: ubuntu-latest
    timeout-minutes: 15
    env:
      local_path: "lib"
      remote_path: "r2:r2-store/src"
    steps:
      - name: "⤵️ Check out code from GitHub"
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: "⏫ Run rclone/r2-store"
        uses: z-shell/.github/actions/rclone@d36763069484d7b5bf3d958e8517dbb682942c82 # v1.0.9
        with:
          config: ${{ secrets.R2_STORE }}
          args: "copy --check-first ${{ env.local_path }} ${{ env.remote_path }}"
          debug: false
