-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (112 loc) · 3.69 KB
/
integration-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
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Integration Test
on:
workflow_dispatch:
inputs:
candidate-branch:
description: Branch to use as the candidate delta
type: string
required: true
jobs:
candidate-specified:
name: Candidate with specified branch
permissions:
id-token: write
contents: write
uses: ./.github/workflows/reusable-update-release-candidate-notes.yml
with:
branch-with-candidate-code: ${{ inputs.candidate-branch }}
candidate-inferred:
needs: [candidate-specified]
name: Candidate with default branch
permissions:
id-token: write
contents: write
uses: ./.github/workflows/reusable-update-release-candidate-notes.yml
publish-release-no-candidate:
name: Publish live release and don't alter candidate
permissions:
id-token: write
contents: write
uses: ./.github/workflows/reusable-create-release-notes.yml
with:
auto-clear-release-candidate-notes: false
tag: integration-test-nc-${{ github.run_id }}
publish-release-clear-candidate:
needs:
[publish-release-no-candidate, candidate-specified, candidate-inferred]
name: Publish live release and clear candidate
permissions:
id-token: write
contents: write
uses: ./.github/workflows/reusable-create-release-notes.yml
with:
tag: integration-test-wc-${{ github.run_id }}
assert-url:
name: Check Release URLs
needs:
[
candidate-specified,
candidate-inferred,
publish-release-no-candidate,
publish-release-clear-candidate,
]
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Assert Release URLs
uses: actions/github-script@v7
with:
script: |
const urls = {
'candidate-specified': '${{ needs.candidate-specified.outputs.URL }}',
'candidate-inferred': '${{ needs.candidate-inferred.outputs.URL }}',
'publish-release-no-candidate': '${{ needs.publish-release-no-candidate.outputs.URL }}',
'publish-release-clear-candidate': '${{ needs.publish-release-clear-candidate.outputs.URL }}',
};
for (const [job, url] of Object.entries(urls)) {
console.log(`Checking URL for ${job}: ${url}`);
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to retrieve release ${url}: ${response.statusText}`);
}
console.log(`URL is valid: ${url}`);
}
cleanup:
name: Cleanup
needs: [assert-url]
if: always()
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Delete Resources
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const tags = ['integration-test-nc-${{ github.run_id }}', 'integration-test-wc-${{ github.run_id }}'];
for (const tag of tags) {
// Fetch the release by tag
const release = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag,
});
// Delete the release
await github.rest.repos.deleteRelease({
owner,
repo,
release_id: release.data.id,
});
// Delete the tag
await github.rest.git.deleteRef({
owner,
repo,
ref: `tags/${tag}`,
});
console.log(`Release and tag deleted: ${tag}`);
}