This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from Bandwidth/DX-2763
DX-2763 Added Cypress tests, project, and workflow
- Loading branch information
Showing
33 changed files
with
12,581 additions
and
8,291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Rollback Release | ||
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. | ||
inputs: | ||
token: | ||
required: true | ||
description: Github Password | ||
outputs: | ||
goodRelease: | ||
description: The tag of the release that we want to rollback to. | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { Octokit } = require("@octokit/core") | ||
const core = require('@actions/core'); | ||
|
||
|
||
async function rollbackRelease() { | ||
const octokit = new Octokit({ | ||
auth: process.env.GITHUB_TOKEN | ||
}) | ||
|
||
const { data } = await octokit.request('GET /repos/Bandwidth/api-docs/releases', { | ||
owner: 'Bandwidth', | ||
repo: 'api-docs' | ||
}) | ||
|
||
const cleanedData = [] | ||
const cleanData = (data) => { | ||
for (const x in data) { | ||
if (data[x].draft === false && data[x].prerelease === false) { | ||
cleanedData.push(data[x]) | ||
} | ||
} | ||
} | ||
|
||
cleanData(data) | ||
cleanedData.sort((a,b) => (a.published_at > b.published_at) ? -1 : ((b.published_at > a.published_at) ? 1 : 0)); | ||
|
||
const badRelease = cleanedData[0].name | ||
const badReleaseId = cleanedData[0].id | ||
const goodRelease = cleanedData[1].name | ||
|
||
core.setOutput("goodRelease", goodRelease) | ||
|
||
await octokit.request(`PATCH /repos/Bandwidth/api-docs/releases/${badReleaseId}`, { | ||
tag_name: badRelease, | ||
draft: true, | ||
}) | ||
|
||
await octokit.request('POST /repos/Bandwidth/api-docs/actions/workflows/3796239/dispatches', { | ||
ref: goodRelease, | ||
}) | ||
} | ||
|
||
rollbackRelease(); |
Oops, something went wrong.