1
0
mirror of synced 2025-12-21 19:06:49 -05:00

Docker image deploy to Heroku (#21248)

* Start parallel Docker image deploy workflows

Co-authored-by: Mike Surowiec <mikesurowiec@users.noreply.github.com>
Co-authored-by: James M. Greene <JamesMGreene@users.noreply.github.com>

* Add early access content build stage

Co-authored-by: Mike Surowiec <mikesurowiec@users.noreply.github.com>

* Create Heroku App script and workflow steps

* Tag the image for Heroku

* Push the image and grab the image ID

* Set app name and image id outputs

* Add parallel deploy script for Docker

* Scope workflow run to 'docker-' and release image to Heroku

* Update .github/workflows/staging-build-pr-docker.yml

Co-authored-by: James M. Greene <JamesMGreene@github.com>

* Exclude Docker workflow

* Cleanup Docker deploys

* Use action sha

Co-authored-by: Mike Surowiec <mikesurowiec@users.noreply.github.com>
Co-authored-by: James M. Greene <JamesMGreene@users.noreply.github.com>
Co-authored-by: James M. Greene <JamesMGreene@github.com>
This commit is contained in:
Robert Sese
2021-09-03 11:34:48 -05:00
committed by GitHub
parent d8b4383dc6
commit cbfba14ac1
8 changed files with 1074 additions and 4 deletions

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env node
import Heroku from 'heroku-client'
import createAppName from './create-staging-app-name.js'
export default async function createApp(pullRequest) {
// Extract some important properties from the PR
const {
number: pullNumber,
base: {
repo: { name: repo },
},
head: { ref: branch },
} = pullRequest
const appName = createAppName({ prefix: 'ghd', repo, pullNumber, branch })
// Check if there's already a Heroku App for this PR, if not create one
let appExists = true
const heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN })
try {
await heroku.get(`/apps/${appName}`)
} catch (e) {
appExists = false
}
if (!appExists) {
try {
const newApp = await heroku.post('/apps', {
body: {
name: appName,
},
})
console.log('Heroku App created', newApp)
} catch (error) {
throw new Error(`Failed to create Heroku App ${appName}. Error: ${error}`)
}
} else {
console.log(`Heroku App ${appName} already exists.`)
}
return appName
}