Skip to content

Commit

Permalink
ci(pie-monorepo): DSW-1330 test conditional message logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Siggery committed Oct 10, 2023
1 parent c066933 commit 5ec38cf
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions .github/workflows/changeset-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,42 @@ jobs:
# - For 'pie-storybook', a distinct message is generated pointing to 'webc.pie.design'.
# - For all other packages, a generic message is generated, including links to the GitHub release and npm.
- name: Generate Slack payload blocks
id: generate_payload
run: |
PACKAGES='[{"name": "wc-nuxt3", "version": "0.30.0"}, {"name": "pie-monorepo", "version": "0.30.0"}, {"name": "@justeattakeaway/pie-button", "version": "0.30.0"}, {"name": "@justeattakeaway/pie-modal", "version": "0.25.0"}, {"name": "pie-storybook", "version": "0.30.0"}, {"name": "pie-docs", "version": "0.30.0"}]'
PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]')
REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]')
COMBINED_PACKAGES=$(echo "[${PRIORITIZED_PACKAGES},${REST_PACKAGES}]" | jq -c 'add')
BLOCKS=$(echo $COMBINED_PACKAGES | jq -c '
[
(.[] |
if .name == "pie-docs" then
{"type": "section", "text": {"type": "mrkdwn", "text": "A new version of the PIE Docs was released! - <https://pie.design|Why not take a look? :eyes:>" }}
elif .name == "pie-storybook" then
{"type": "section", "text": {"type": "mrkdwn", "text": "PIE Storybook was released - <https://webc.pie.design|Check it out! :pie_team_logo:>" }}
else empty
end
),
{"type": "section", "text": {"type": "mrkdwn", "text": "New versions are available for the following components:"}},
(.[] |
select(.name != "pie-docs" and .name != "pie-storybook") |
{"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | <https://github.com/justeattakeaway/pie/releases/tag/\(.name)@\(.version)|Changelog> | <https://www.npmjs.com/package/\(.name)|npm>" }}
)
]
')
echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV
id: generate_payload
run: |
PACKAGES='[...]' # Your package list here
PRIORITIZED_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select(.name == "pie-docs" or .name == "pie-storybook")]')
REST_PACKAGES=$(echo $PACKAGES | jq -c '[.[] | select((.name != "pie-docs" and .name != "pie-storybook") and (.name | startswith("wc-") | not) and .name != "pie-monorepo")]')

PRIORITIZED_BLOCKS=$(echo $PRIORITIZED_PACKAGES | jq -c '
if length > 0 then
[.[] |
if .name == "pie-docs" then
{"type": "section", "text": {"type": "mrkdwn", "text": "A new version of the PIE Docs was released! - <https://pie.design|Why not take a look? :eyes:>" }}
elif .name == "pie-storybook" then
{"type": "section", "text": {"type": "mrkdwn", "text": "PIE Storybook was released - <https://webc.pie.design|Check it out! :pie_team_logo:>" }}
else empty
end
]
else
[]
end
')
REST_COMPONENT_BLOCKS=$(echo $REST_PACKAGES | jq -c '
if length > 0 then
[{"type": "section", "text": {"type": "mrkdwn", "text": "New versions are available for the following components:"}}] +
map(
{"type": "section", "text": {"type": "mrkdwn", "text": "- *\(.name | sub("@justeattakeaway/pie-"; "") | (.[0:1] | ascii_upcase) + .[1:])* was updated to `\(.version)` | <https://github.com/justeattakeaway/pie/releases/tag/\(.name)@\(.version)|Changelog> | <https://www.npmjs.com/package/\(.name)|npm>" }}
)
else
[]
end
')
BLOCKS=$(echo "[${PRIORITIZED_BLOCKS},${REST_COMPONENT_BLOCKS}]" | jq -c 'add')

echo "BLOCKS=$BLOCKS" >> $GITHUB_ENV

- name: Send a Slack notification on publish
# if: steps.changesets-main.outcome == 'success'
Expand Down

0 comments on commit 5ec38cf

Please sign in to comment.