-
Notifications
You must be signed in to change notification settings - Fork 186
186 lines (167 loc) · 7.08 KB
/
pull_request_packages_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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: 'Pull Request / Packages: Deploy'
# Note: display_title не задокументирован
run-name: '${{ github.event.workflow_run.display_title }} • ${{ github.event.workflow_run.head_branch }} • ${{ github.event.workflow_run.id }}'
on:
workflow_run:
workflows: ['Pull Request / Packages']
types: [completed]
env:
PR_HEAD_REPOSITORY_FULL_NAME: ${{ github.event.workflow_run.head_repository.full_name }}
PR_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
AWS_S3_URL: https://${{ vars.AWS_BUCKET }}.${{ vars.AWS_ENDPOINT }}
jobs:
pr_workflow_payload:
if: ${{ github.event.workflow_run.event == 'pull_request' }}
name: Call reusable workflow
uses: ./.github/workflows/reusable_workflow_pr_worfklow_payload.yml
with:
action: download
deploy_test_coverage:
needs: pr_workflow_payload
if: ${{ needs.pr_workflow_payload.outputs.status == 'success' }}
runs-on: ubuntu-latest
name: Deploy test coverage
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.PR_HEAD_REPOSITORY_FULL_NAME }}
ref: ${{ env.PR_HEAD_BRANCH }}
persist-credentials: false
- name: Download artifact
id: artifact
uses: VKCOM/gh-actions/shared/download-workflow-artifact@main
with:
name: test-output
- name: Upload coverage to Codecov
if: ${{ steps.artifact.outputs.found_artifact == 'true' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
files: .nyc_output/coverage-final.json
override_branch: ${{ env.PR_HEAD_BRANCH }}
override_commit: ${{ env.PR_HEAD_SHA }}
override_pr: ${{ needs.pr_workflow_payload.outputs.pr_number }}
fail_ci_if_error: true
verbose: true
deploy_playwright_report:
needs: pr_workflow_payload
if: ${{ needs.pr_workflow_payload.outputs.status == 'success' }}
runs-on: ubuntu-latest
name: Deploy Playwright Report and create comment
steps:
- name: Download artifact
id: artifact
uses: VKCOM/gh-actions/shared/download-workflow-artifact@main
with:
name: playwright-report
path: playwright-report/
- name: Deploy Playwright Report
if: ${{ steps.artifact.outputs.found_artifact == 'true' }}
id: deploy
uses: VKCOM/gh-actions/VKUI/s3@main
with:
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.AWS_SECRET_KEY }}
awsBucket: ${{ vars.AWS_BUCKET }}
awsEndpoint: https://${{ vars.AWS_ENDPOINT }}
command: upload
commandUploadSrc: playwright-report/
commandUploadDist: pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/playwright-report
- name: Report
if: ${{ steps.deploy.outcome == 'success' }}
uses: VKCOM/gh-actions/VKUI/reporter@main
with:
prNumber: ${{ needs.pr_workflow_payload.outputs.pr_number }}
playwrightReportURL: ${{ env.AWS_S3_URL }}/pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/playwright-report/index.html
token: ${{ secrets.GITHUB_TOKEN }}
deploy_styleguide:
needs: pr_workflow_payload
if: ${{ needs.pr_workflow_payload.outputs.status == 'success' }}
runs-on: ubuntu-latest
name: Deploy docs (styleguide)
outputs:
url: ${{ steps.url.outputs.value }}
steps:
- name: Download styleguide dist artifact
id: artifact
uses: VKCOM/gh-actions/shared/download-workflow-artifact@main
with:
name: styleguide-dist
path: styleguide-dist/
- name: Upload styleguide S3
if: ${{ steps.artifact.outputs.found_artifact == 'true' }}
id: deploy
uses: VKCOM/gh-actions/VKUI/s3@main
with:
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.AWS_SECRET_KEY }}
awsBucket: ${{ vars.AWS_BUCKET }}
awsEndpoint: https://${{ vars.AWS_ENDPOINT }}
command: upload
commandUploadSrc: styleguide-dist/
commandUploadDist: pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/styleguide
- name: Create doc url
if: ${{ steps.deploy.outcome == 'success' }}
id: url
run: echo "value=${{ env.AWS_S3_URL }}/pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/styleguide/index.html" >> $GITHUB_OUTPUT
deploy_storybook:
needs: pr_workflow_payload
if: ${{ needs.pr_workflow_payload.outputs.status == 'success' }}
runs-on: ubuntu-latest
name: Deploy docs (storybook)
outputs:
url: ${{ steps.url.outputs.value }}
steps:
- name: Download dist artifact
id: artifact
uses: VKCOM/gh-actions/shared/download-workflow-artifact@main
with:
name: storybook-dist
path: storybook-dist/
- name: Upload
if: ${{ steps.artifact.outputs.found_artifact == 'true' }}
id: deploy
uses: VKCOM/gh-actions/VKUI/s3@main
with:
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }}
awsSecretAccessKey: ${{ secrets.AWS_SECRET_KEY }}
awsBucket: ${{ vars.AWS_BUCKET }}
awsEndpoint: https://${{ vars.AWS_ENDPOINT }}
command: upload
commandUploadSrc: storybook-dist/
commandUploadDist: pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/storybook
- name: Create doc url
if: ${{ steps.deploy.outcome == 'success' }}
id: url
run: echo "value=${{ env.AWS_S3_URL }}/pull/${{ needs.pr_workflow_payload.outputs.pr_number }}/${{ env.PR_HEAD_SHA }}/storybook/index.html" >> $GITHUB_OUTPUT
docs_comment:
needs:
- deploy_storybook
- deploy_styleguide
- pr_workflow_payload
if: ${{ needs.deploy_styleguide.outputs.url != '' || needs.deploy_storybook.outputs.url != '' }}
runs-on: ubuntu-latest
name: Docs comment
steps:
- name: Find docs URLs comment
uses: peter-evans/find-comment@v3
id: find_url_comment
with:
issue-number: ${{ needs.pr_workflow_payload.outputs.pr_number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- docs_urls -->
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find_url_comment.outputs.comment-id }}
issue-number: ${{ needs.pr_workflow_payload.outputs.pr_number }}
body: |
<!-- docs_urls -->
## 👀 Docs deployed
- ${{ (needs.deploy_styleguide.outputs.url != '' && '✅') || '❌' }} [Styleguide](${{ needs.deploy_styleguide.outputs.url }})
- ${{ (needs.deploy_storybook.outputs.url != '' && '✅') || '❌' }} [Storybook](${{ needs.deploy_storybook.outputs.url }})
Commit ${{ env.PR_HEAD_SHA }}
edit-mode: replace