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

Commit

Permalink
Merge pull request #691 from Bandwidth/DX-2763
Browse files Browse the repository at this point in the history
DX-2763 Added Cypress tests, project, and workflow
  • Loading branch information
brianluisgomez authored Sep 29, 2022
2 parents a9f5cc8 + bb70264 commit 0424b2d
Show file tree
Hide file tree
Showing 33 changed files with 12,581 additions and 8,291 deletions.
12 changes: 12 additions & 0 deletions .github/actions/rollback_release/action.yaml
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'
43 changes: 43 additions & 0 deletions .github/actions/rollback_release/index.js
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();
Loading

0 comments on commit 0424b2d

Please sign in to comment.