Skip to content

Commit

Permalink
Merge pull request #574 from clearlydefined/elr/ver-sha
Browse files Browse the repository at this point in the history
add sha and version to ‘/‘ endpoint
  • Loading branch information
ljones140 authored Oct 15, 2024
2 parents 3e1fdc8 + 99cb4a3 commit ef89a38
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
build-and-deploy:
name: Build and Deploy
needs: upload-package-lock-json
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v2.0.0
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v3.0.0
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }}
Expand Down
7 changes: 6 additions & 1 deletion DevDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
FROM node:18-bullseye
ENV APPDIR=/opt/service

# Set environment variables from build arguments
ARG BUILD_NUMBER=0
ENV CRAWLER_BUILD_NUMBER=$BUILD_NUMBER
ENV BUILD_NUMBER=$APP_VERSION
ARG APP_VERSION="UNKNOWN"
ENV APP_VERSION=$APP_VERSION
ARG BUILD_SHA="UNKNOWN"
ENV BUILD_SHA=$BUILD_SHA

# Ruby and Python Dependencies
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev cmake python3 python3-dev python3-pip xz-utils libxml2-dev libxslt1-dev libpopt0 && \
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
FROM node:18-bullseye
ENV APPDIR=/opt/service

ARG BUILD_NUMBER=0
ENV CRAWLER_BUILD_NUMBER=$BUILD_NUMBER
# Set environment variables from build arguments
ARG APP_VERSION="UNKNOWN"
ENV APP_VERSION=$APP_VERSION
ARG BUILD_SHA="UNKNOWN"
ENV BUILD_SHA=$BUILD_SHA

# Ruby and Python Dependencies
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev cmake python3 python3-dev python3-pip xz-utils libxml2-dev libxslt1-dev libpopt0 && \
Expand Down
4 changes: 3 additions & 1 deletion config/cdConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ module.exports = {
attenuation: {
ttl: 3000
}
}
},
appVersion: config.get('APP_VERSION'),
buildsha: config.get('BUILD_SHA')
}
}
4 changes: 1 addition & 3 deletions ghcrawler/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function configureApp(service, logger) {
app.use('/requests', require('./routes/requests')(service))

// to keep AlwaysOn flooding logs with errors
app.get('/', (request, response) => {
response.helpers.send.noContent()
})
app.use('/', require('./routes/index')(config.get('BUILD_SHA'), config.get('APP_VERSION')))

// Catch 404 and forward to error handler
const requestHandler = (request, response, next) => {
Expand Down
20 changes: 20 additions & 0 deletions ghcrawler/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation and others. Licensed under the MIT license.
// SPDX-License-Identifier: MIT
const express = require('express')
const router = express.Router()

router.get('/', function (req, res) {
const msg = `{ "status": "OK", "version": "${version}", "sha": "${sha}" }`
res.status(200).send(msg)
})

module.exports = router

let version
let sha
function setup(buildsha, appVersion) {
version = appVersion
sha = buildsha
return router
}
module.exports = setup
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const uuid = require('node-uuid')
const logger = require('./providers/logging/logger')({
crawlerId: config.get('CRAWLER_ID') || uuid.v4(),
crawlerHost: config.get('CRAWLER_HOST'),
buildNumber: config.get('CRAWLER_BUILD_NUMBER') || 'local'
appVersion: config.get('APP_VERSION') || 'local'
})

run(defaults, logger, searchPath, maps)

0 comments on commit ef89a38

Please sign in to comment.