name: Sync-Releases

on:
  schedule:
    - cron:  '0 3 * * *'
  workflow_dispatch:

jobs:
  update-releasesmd:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Update dependencies
        id: vars
        run: |
          curl -o content/releases.md https://raw.githubusercontent.com/containerd/containerd/master/RELEASES.md
          sed -i'' 's,^# Versioning and Release$,---\ntitle: Versioning and release\n---,' content/releases.md
          sed -i'' 's,| \[api/\](api),| \[gRPC API\](#grpc),' content/releases.md
          sed -i'' 's, See \[api/\](api) for details.,,' content/releases.md
          sed -i'' 's,^### GRPC API,### GRPC API {#grpc},' content/releases.md
          sed -i'' 's,\./docs/,https://github.com/containerd/containerd/blob/main/docs/,' content/releases.md
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v7
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: |
            keep releases.md in sync with containerd/containerd

            Signed-off-by: Samuel Karp <samuelkarp+automated@google.com>
          committer: Samuel Karp <samuelkarp@google.com>
          author: Samuel Karp <samuelkarp+automated@google.com>
          title: Automated RELEASES.md sync update
          body: This is an auto-generated PR to sync updates in the main containerd project's RELEASES.md file.
          branch: dep-updates
