Skip to content

Commit

Permalink
get sha only once and store in configs
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Jan 31, 2024
1 parent 89c0142 commit 6aac9c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build_and_deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ jobs:
"name": "DOCKER_REGISTRY_SERVER_PASSWORD",
"value": "${{ secrets.REGISTRY_PASSWORD }}",
"slotSetting": false
},
{
"name": "BUILD_SHA",
"value": "${{ github.sha }}",
"slotSetting": false
}
]
Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function createApp(config) {

app.use(require('./middleware/querystring'))

app.use('/', require('./routes/index'))
app.use('/', require('./routes/index')(config.buildsha))
app.use('/origins/github', require('./routes/originGitHub')())
app.use('/origins/crate', require('./routes/originCrate')())
app.use('/origins/pod', require('./routes/originPod')())
Expand Down
3 changes: 2 additions & 1 deletion bin/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ module.exports = {
serviceKey: config.get('APPINSIGHTS_SERVICE_APIKEY'),
crawlerId: config.get('APPINSIGHTS_CRAWLER_APPLICATIONID'),
crawlerKey: config.get('APPINSIGHTS_CRAWLER_APIKEY')
}
},
buildsha : config.get('BUILD_SHA')
}
10 changes: 7 additions & 3 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ const express = require('express')
const router = express.Router()

router.get('/', function(req, res) {
const sha = require('child_process')
.execSync('git rev-parse HEAD')
.toString().trim()
const msg = `{ "status": "OK", "sha": "${sha}" }`
res.status(200).send(msg)
})

module.exports = router

let sha
function setup(buildsha) {
sha = buildsha
return router
}
module.exports = setup

0 comments on commit 6aac9c9

Please sign in to comment.