-
Notifications
You must be signed in to change notification settings - Fork 350
100 lines (91 loc) · 4.16 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
# This workflow will run changesets depending on two different scenarios:
#
# 1. If we are landing a specific commit into main (Author PR), then
# changesets will check if there are changes verifying the Markdown files
# generated automatically:
#
# a) There are new versions and there's NO Release PR, then the changesets
# action will create a new Release PR.
#
# b) There's a Release PR, then the changesets action will update the
# existing Release PR with the new commit.
#
# NOTE: (in both cases, changesets will modify the new version in
# package.json for each package, and will remove the MD files as part of the
# Release PR).
#
# 2. If we are landing the Release PR into main, then the changesets action
# will publish the changes to npm.
#
# For more info about this workflow, see:
# https://github.com/changesets/action#usage
jobs:
release:
name: Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install & cache node_modules
uses: ./.github/actions/shared-node-cache
with:
node-version: ${{ matrix.node-version }}
- name: Build Storybook
# Generate a static version of storybook inside "storybook-static/"
run: yarn build-storybook
- name: Deploy to GitHub pages
uses: JamesIves/[email protected]
with:
# The branch the action should deploy to.
branch: gh-pages
# The folder the action should deploy.
folder: storybook-static
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn publish:ci
env:
# We use a Personal Access Token here rather than the GITHUB_TOKEN
# so that it will trigger our other actions. The token has to be on
# the account of someone with appropriate access levels and given the
# repo scope.
GITHUB_TOKEN: ${{ secrets.KHAN_ACTIONS_BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Send a Slack notification if a publish fails
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_EXERCISENEXT_WEBHOOK }}
SLACK_CHANNEL: team-lems-perseus
SLACK_MSG_AUTHOR: ${{ github.event.pull_request.user.login }}
SLACK_USERNAME: GithubGoose
SLACK_ICON_EMOJI: ":goose:"
SLACK_MESSAGE: "Something went wrong with the release of ${{ github.event.repository.name }}. \nPlease check the logs → https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SLACK_TITLE: "Oops! I'm the Bad News Goose!"
SLACK_FOOTER: Perseus Slack Notification
MSG_MINIMAL: true
- name: Send a Slack notification for web if a publish happens
if: steps.changesets.outputs.published == 'true'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_EXERCISENEXT_WEBHOOK }}
SLACK_CHANNEL: team-lems-perseus
SLACK_MSG_AUTHOR: ${{ github.event.pull_request.user.login }}
SLACK_USERNAME: GithubGoose
SLACK_ICON_EMOJI: ":goose:"
SLACK_MESSAGE: "A new version of ${{ github.event.repository.name }} was published! \nRelease notes → https://github.com/${{ github.repository }}/releases/"
SLACK_TITLE: "New Perseus release!"
SLACK_FOOTER: Perseus Slack Notification
MSG_MINIMAL: true