-
Notifications
You must be signed in to change notification settings - Fork 186
95 lines (86 loc) · 4.13 KB
/
publish_deploy.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
name: 'Publish: Deploy (⚠️ use manually call only if necessary)'
# Note: display_title не задокументирован из-за чего в IDE может подчёркиваться строка
run-name: "${{ github.event_name == 'workflow_run' && format('{0}: Deploy • {1} • {2}', github.event.workflow_run.display_title, github.event.workflow_run.head_branch, github.event.workflow_run.id) || format('Publish {0} {1}@{2}: Deploy (⚠️ manually run)', inputs.publish_type, inputs.package_name, inputs.next_version) }}"
on:
workflow_run:
workflows: ['Publish pre-release', 'Publish release']
types: [completed]
# Note: только на случай, если потребуется ручной запуск
workflow_dispatch:
inputs:
package_name:
description: "package's name:"
required: true
type: choice
options:
- '@vkontakte/vkui'
next_version:
description: "package's version (without 'v'):"
required: true
type: string
publish_type:
description: "⚠️ before change to 'release' make sure this is the case"
default: 'pre-release'
type: choice
options:
- 'release'
- 'pre-release'
env:
CHECKOUT_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref }}
jobs:
payload:
name: Prepare payload data
runs-on: ubuntu-latest
outputs:
package_name: ${{ steps.publish_workflow_payload.outputs.package_name || inputs.package_name }}
next_version: ${{ steps.publish_workflow_payload.outputs.next_version || inputs.next_version }}
is_for_prerelease: ${{ contains(github.event.workflow_run.name, 'Publish pre-release') || contains(inputs.publish_type, 'pre-release') }}
steps:
- name: Download artifact (if it is 'workflow_run')
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.event == 'workflow_dispatch' && github.event.workflow_run.conclusion == 'success' }}
id: artifact
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
name: publish_workflow_payload
path: publish_workflow_payload/
run-id: ${{ github.event.workflow_run.id }}
- name: Parse artifact
if: ${{ steps.artifact.conclusion == 'success' }}
id: publish_workflow_payload
run: |
echo "package_name=$(cat publish_workflow_payload/package_name.txt)" >> $GITHUB_OUTPUT
echo "next_version=$(cat publish_workflow_payload/next_version.txt)" >> $GITHUB_OUTPUT
deploy_vkui_docs:
needs: [payload]
if: ${{ success() && needs.payload.outputs.package_name == '@vkontakte/vkui' && needs.payload.outputs.next_version }}
runs-on: ubuntu-latest
name: Deploy @vkontakte/vkui docs
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.CHECKOUT_BRANCH }}
- name: Setting up the repository environment
uses: ./.github/actions/setup
- name: Creating docs for pre-release
if: ${{ fromJSON(needs.payload.outputs.is_for_prerelease) == true }}
run: |
yarn run docs:styleguide:build --dist dist/${{ needs.payload.outputs.next_version }}
yarn run docs:storybook:build -o ../../styleguide/dist/${{ needs.payload.outputs.next_version }}/playground
- name: Creating docs for release
if: ${{ fromJSON(needs.payload.outputs.is_for_prerelease) != true }}
run: |
yarn run docs:styleguide:build --dist dist
yarn run docs:storybook:build -o ../../styleguide/dist/playground
mkdir -p styleguide/${{ needs.payload.outputs.next_version }}
cp -R styleguide/dist/* styleguide/${{ needs.payload.outputs.next_version }}
mv styleguide/${{ needs.payload.outputs.next_version }} styleguide/dist
- name: Publishing doc
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
branch: gh-pages
folder: styleguide/dist
clean: false
force: false