---
name: updatecli-compose

on:
  workflow_dispatch:
  schedule:
    - cron: "0 6 * * *"

permissions:
  contents: read

jobs:
  compose:
    if: github.repository == 'elastic/elasticsearch'
    runs-on: ubuntu-latest
    permissions:
      contents: write
      packages: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4

      - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - uses: elastic/oblt-actions/updatecli/run@v1
        with:
          command: --experimental compose diff
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: elastic/oblt-actions/updatecli/run@v1
        with:
          command: --experimental compose apply
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}