name: po-refresh
on:
  schedule:
    # Run this on Tuesday evening (UTC), so that it's ready for release on
    # Wednesday, with some spare time
    - cron: '0 18 * * 2'
  # can be run manually on https://github.com/osbuild/cockpit-composer/actions
  workflow_dispatch:
jobs:
  po-refresh:
    runs-on: ubuntu-20.04
    steps:
      - name: Set up dependencies
        run: |
          sudo apt update
          sudo apt install -y --no-install-recommends npm make gettext

      - name: Set up configuration and secrets
        run: |
          printf '[user]\n\tname = Cockpit Project\n\temail=cockpituous@gmail.com\n' > ~/.gitconfig
          echo '${{ secrets.GITHUB_TOKEN }}' > ~/.config/github-token
          # po-refresh pushes to weblate repo via https://github.com, that needs our cockpituous token
          git config --global credential.helper store
          echo 'https://token:${{ secrets.COCKPITUOUS_TOKEN }}@github.com' >> ~/.git-credentials

      - name: Clone repository
        uses: actions/checkout@v2

      - name: Run po-refresh bot
        run: |
          make bots
          bots/po-refresh
