-
Notifications
You must be signed in to change notification settings - Fork 40
119 lines (108 loc) · 4.42 KB
/
PR_build_extension.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
name: PR Build extension
on:
pull_request:
paths-ignore:
- 'LICENSE'
- 'README.md'
- 'SECURITY.md'
- '.vscode/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/CODEOWNERS'
env:
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
PRISMA_TELEMETRY_INFORMATION: 'language-tools PR_build_extension.yml'
SLACK_USERNAME: Prismo
SLACK_ICON_EMOJI: ':ship:'
SLACK_MSG_AUTHOR: prisma-bot
jobs:
build:
name: Build extension
# Only runs for Prisma repo, as this will fail on a PR from a fork
if: github.repository == 'prisma/language-tools'
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
tag_name: ${{ steps.names.outputs.tag_name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
# Build the extension
- name: Install Dependencies
run: npm install && npm run bootstrap
- name: Build all packages
run: npm run compile
- name: Replace Readme for marketplace
run: node scripts/change_readme.js dev
- name: Update VS Code extension name
run: |
node scripts/update_package_json_file_PR_build.js
env:
PR_NUMBER: ${{ github.event.number }}
# So we can use the local language server and don't have to publish it to npm first
# Note that linked node_modules are not supported https://github.com/microsoft/vscode-vsce/issues/203
- name: Copy language-server dist directory inside vscode package
run: |
cp -R packages/language-server packages/vscode
rm -R packages/vscode/language-server/src packages/vscode/language-server/test
- name: Build vsix
run: cd packages/vscode && npm run package -- --out=prisma.vsix
# Upload to the current job run
# This is very limited: Only 90 days rentention and cannot get a link easily
- uses: actions/upload-artifact@v3
with:
name: pr-artifact
path: ./packages/vscode/*.vsix
# Add artifact as a commit on the `artifacts` branch
# and post message with the link in the PR
- name: Add artifact to PR
# Skip for Renovate (only build)
if: "!contains(github.actor, 'renovate')"
uses: gavv/[email protected]
with:
commit: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
artifacts-branch: artifacts
artifacts-dir: pull-request-artifacts
artifacts: |
./packages/vscode/prisma.vsix
# Additionally post a comment with a link to GitPod that can use built extension instantly
- name: Find existing comment
if: "!contains(github.actor, 'renovate')"
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'via GitPod'
- name: Create comment
if: "!contains(github.actor, 'renovate') && steps.fc.outputs.comment-id == ''"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: '[Try this extension build via GitPod](https://gitpod.io/#vsix=https%3A%2F%2Fgithub.com%2Fprisma%2Flanguage-tools%2Fblob%2Fartifacts%2Fpull-request-artifacts%2Fpr${{ github.event.pull_request.number }}-prisma.vsix%3Fraw%3Dtrue/https://github.com/prisma/language-tools-gitpod)'
slack:
name: Send slack notification
runs-on: ubuntu-latest
needs: [build]
if: always() && github.repository == 'prisma/language-tools'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: 'Set current job url in SLACK_FOOTER env var'
if: ${{ always() }}
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV
- name: Slack Notification on Failure
if: ${{ failure() || needs.build.result == 'failure' }}
uses: rtCamp/[email protected]
env:
SLACK_TITLE: 'PR Build extension failed :x:'
SLACK_COLOR: '#FF0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_FAILURES }}
SLACK_CHANNEL: feed-language-tools-failures