"divider" ], [ "type" => "header", "text" => [ "type" => "plain_text", "text" => "Draw Attention Pro Release.\n" ] ], [ "type" => "section", "text" => [ "type" => "mrkdwn", "text" => "You can .\n" ] ], [ "type" => "section", "text" => [ "type" => "mrkdwn", "text" => ":white_check_mark: 4.{$values['version']}\n:white_check_mark: 3.{$values['version']}\n:white_check_mark: 2.{$values['version']}\n:no_entry: 1.{$values['version']} (will be released separately)\n" ] ], ]; $pattern = '/PR:#(\d+)(.*)/'; try { foreach (json_decode(CHANGELOG_JSON) as $key => $array_of_prs) { $formatted_key = str_replace('##', '', $key); $slack_payload_blocks[] = [ "type" => "header", "text" => [ "type" => "plain_text", "text" => $formatted_key ] ]; foreach ($array_of_prs as $pr) { preg_match($pattern, $pr, $matches); $pr_number = $matches[1]; $pr_title = $matches[2]; $slack_payload_blocks[] = [ "type" => "section", "text" => [ "type" => "mrkdwn", "text" => " $pr_title" ] ]; } } } catch (\Throwable $th) { echo "Failed to parse CHANGELOG_JSON"; } $slack_payload = [ "text" => "\n\n\nDraw Attention Pro Release {$values['version']}\nChangelog:\n" . CHANGELOG_STRING, "blocks" => $slack_payload_blocks, ]; $json = json_encode($slack_payload, JSON_PRETTY_PRINT); $fp = fopen($values["out"], 'w'); fwrite($fp, $json); fclose($fp);