diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index 5bda39ab..7fe8f57d 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -1,13 +1,15 @@ name: Delete old workflow runs on: + schedule: + - cron: "0 4 1 * *" workflow_dispatch: inputs: days: - description: 'Number of days.' + description: "Number of days." required: true default: 1 minimum_runs: - description: 'The minimum runs to keep for each workflow.' + description: "The minimum runs to keep for each workflow." required: true default: 0 @@ -21,4 +23,4 @@ jobs: token: ${{ github.token }} repository: ${{ github.repository }} retain_days: ${{ github.event.inputs.days }} - keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} \ No newline at end of file + keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} diff --git a/src/Utils.hs b/src/Utils.hs index 9335591a..07b5941a 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -281,7 +281,16 @@ sliceOnN t n = then (l_acc, l_v) else (unlined, mempty) +removeAllEmptyLines :: T.Text -> T.Text +removeAllEmptyLines = fst . T.foldl' step tuple_acc + where + tuple_acc = (mempty, 0) :: (T.Text, Int) + step (acc, counter) val + | val == '\n' && counter == 0 = (acc `T.append` T.singleton val, 1) + | val == '\n' && counter == 1 = (acc, 0) + | otherwise = (acc `T.append` T.singleton val, counter) + sliceIfAboveTelegramMax :: T.Text -> [T.Text] sliceIfAboveTelegramMax msg | T.length msg <= 4096 = pure msg - | otherwise = sliceOnN msg 4096 \ No newline at end of file + | otherwise = removeAllEmptyLines <$> sliceOnN msg 4096 \ No newline at end of file