Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 0424b2d

Browse files
Merge pull request #691 from Bandwidth/DX-2763
DX-2763 Added Cypress tests, project, and workflow
2 parents a9f5cc8 + bb70264 commit 0424b2d

33 files changed

+12581
-8291
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Rollback Release
2+
description: Takes the latest release and converts it to a draft and then kicks off a workflow dispatch to publish the previous release to AWS.
3+
inputs:
4+
token:
5+
required: true
6+
description: Github Password
7+
outputs:
8+
goodRelease:
9+
description: The tag of the release that we want to rollback to.
10+
runs:
11+
using: 'node16'
12+
main: 'index.js'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const { Octokit } = require("@octokit/core")
2+
const core = require('@actions/core');
3+
4+
5+
async function rollbackRelease() {
6+
const octokit = new Octokit({
7+
auth: process.env.GITHUB_TOKEN
8+
})
9+
10+
const { data } = await octokit.request('GET /repos/Bandwidth/api-docs/releases', {
11+
owner: 'Bandwidth',
12+
repo: 'api-docs'
13+
})
14+
15+
const cleanedData = []
16+
const cleanData = (data) => {
17+
for (const x in data) {
18+
if (data[x].draft === false && data[x].prerelease === false) {
19+
cleanedData.push(data[x])
20+
}
21+
}
22+
}
23+
24+
cleanData(data)
25+
cleanedData.sort((a,b) => (a.published_at > b.published_at) ? -1 : ((b.published_at > a.published_at) ? 1 : 0));
26+
27+
const badRelease = cleanedData[0].name
28+
const badReleaseId = cleanedData[0].id
29+
const goodRelease = cleanedData[1].name
30+
31+
core.setOutput("goodRelease", goodRelease)
32+
33+
await octokit.request(`PATCH /repos/Bandwidth/api-docs/releases/${badReleaseId}`, {
34+
tag_name: badRelease,
35+
draft: true,
36+
})
37+
38+
await octokit.request('POST /repos/Bandwidth/api-docs/actions/workflows/3796239/dispatches', {
39+
ref: goodRelease,
40+
})
41+
}
42+
43+
rollbackRelease();

0 commit comments

Comments
 (0)