-
-
Notifications
You must be signed in to change notification settings - Fork 5
108 lines (100 loc) · 3.56 KB
/
test.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
name: Dependabot Deployments and Comments
on:
pull_request:
branches: [main]
types: [opened, synchronize, closed]
paths:
- "package.json"
- "package-lock.json"
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
secret: ['HYPERCRITICAL_SECRET', 'TEST_KEY']
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm i -g vercel
env:
TEST_KEY: ${{ secrets.HYPERCRITICAL_SECRET }}
- name: Comment on Vercel CLI Installation
uses: actions/github-script@v7
with:
github-token: ${{ secrets[matrix.secret] }}
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const message = 'Vercel CLI installed successfully.';
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: message
});
- name: Deploy to Vercel Preview
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_BOT_DEPLOY }}
run: vercel --token $VERCEL_TOKEN --preview
- name: Comment on Deployment
uses: actions/github-script@v7
with:
github-token: ${{ secrets[matrix.secret] }}
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const message = 'Deployment to Vercel preview started.';
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: message
});
continue-on-error: true
label-and-manage:
runs-on: ubuntu-latest
strategy:
matrix:
secret: ['HYPERCRITICAL_SECRET', 'TEST_KEY']
steps:
- uses: actions/checkout@v2
- name: Label Dependabot PRs
uses: actions/github-script@v7
with:
github-token: ${{ secrets[matrix.secret] }}
script: |
console.log(`Pull Request Number: ${context.issue.number}`);
const { owner, repo } = context.repo;
const pr_number = context.issue.number;
const pr = await github.rest.pulls.get({ owner, repo, pull_number: pr_number });
if (pr.data.user.login === 'dependabot[bot]') {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: pr_number,
labels: ['dependencies']
});
const message = `PR #${pr_number} labeled as dependency on ${new Date().toISOString()}.`;
await github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body: message
});
}
- name: Comment on Merge
if: github.event.pull_request.merged == true
uses: actions/github-script@v7
with:
github-token: ${{ secrets[matrix.secret] }}
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const message = 'PR successfully merged! Branch been deleted by Dependabot.';
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: message
});