Repository navigation
147 lines (128 loc) · 4.95 KB
/
Copy pathpr.yml
File metadata and controls
147 lines (128 loc) · 4.95 KB
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
name: pr
on:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
permissions: {}
jobs:
Build:
name: Build
permissions:
statuses: write
pull-requests: write
uses: ./.github/workflows/_build.yml
secrets:
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
BuildDocs:
name: Build Docs
permissions:
statuses: write
pull-requests: write
uses: ./.github/workflows/_build-docs.yml
Dependabot:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
permission-contents: read
permission-pull-requests: write
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ steps.app-token.outputs.token }}
- name: Apply dependency labels
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
UPDATE_TYPE: ${{ steps.metadata.outputs.update-type }}
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const prNumber = context.issue.number;
const updateType = process.env.UPDATE_TYPE;
// Get current labels
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const currentLabelNames = currentLabels.map(label => label.name);
const conflictingLabels = ['major', 'minor', 'patch'];
// Remove conflicting labels if they exist
for (const conflictingLabel of conflictingLabels) {
if (currentLabelNames.includes(conflictingLabel)) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: conflictingLabel
});
console.log(`Removed conflicting label: ${conflictingLabel}`);
}
}
// Determine specific dependency label based on update type
let specificLabel = null;
switch (updateType) {
case 'version-update:semver-major':
case 'version-update:semver-premajor':
specificLabel = 'majorDependency';
break;
case 'version-update:semver-minor':
case 'version-update:semver-preminor':
specificLabel = 'minorDependency';
break;
case 'version-update:semver-patch':
case 'version-update:semver-prepatch':
specificLabel = 'patchDependency';
break;
default:
console.log(`Unknown update type: ${updateType}, will use dependencies only`);
}
const labelsToAdd = [];
// Add the dependencies label if it's not already present (required for CI)
if (!currentLabelNames.includes('dependencies')) {
labelsToAdd.push('dependencies');
}
// Add specific dependency label if determined and not already present
if (specificLabel && !currentLabelNames.includes(specificLabel)) {
labelsToAdd.push(specificLabel);
}
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: labelsToAdd
});
console.log(`Added labels: ${labelsToAdd.join(', ')}`);
} else {
console.log('All required labels already present');
}
ReleaseDraftValidation:
name: Validate Release Drafter
runs-on: ubuntu-22.04
steps:
- uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
permission-contents: read
permission-pull-requests: read
- name: Validate release drafting without publishing
uses: release-drafter/release-drafter@d1a19e60e81a7e650d00a7de9277f87e439117ea # v7.11.0
with:
token: ${{ steps.app-token.outputs.token }}
dry-run: true
commitish: ${{ github.event.pull_request.base.ref }}