From ce50ee8f7c691b4694377f4ab848b6cfe49a4864 Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Tue, 30 Apr 2024 13:57:55 -0400 Subject: [PATCH 1/8] =?UTF-8?q?add=20sha=20and=20version=20to=20=E2=80=98/?= =?UTF-8?q?=E2=80=98=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DevDockerfile | 7 ++++++- Dockerfile | 7 ++++++- config/cdConfig.js | 4 +++- ghcrawler/app.js | 4 +--- ghcrawler/routes/index.js | 20 ++++++++++++++++++++ 5 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 ghcrawler/routes/index.js diff --git a/DevDockerfile b/DevDockerfile index d08e13a9..8133b738 100644 --- a/DevDockerfile +++ b/DevDockerfile @@ -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 && \ diff --git a/Dockerfile b/Dockerfile index 039d909e..86ca915e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 && \ diff --git a/config/cdConfig.js b/config/cdConfig.js index d71b6bd6..b6b72828 100644 --- a/config/cdConfig.js +++ b/config/cdConfig.js @@ -135,6 +135,8 @@ module.exports = { attenuation: { ttl: 3000 } - } + }, + appVersion: config.get('APP_VERSION'), + buildsha: config.get('BUILD_SHA') } } diff --git a/ghcrawler/app.js b/ghcrawler/app.js index 20af0261..b61a8a0c 100644 --- a/ghcrawler/app.js +++ b/ghcrawler/app.js @@ -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) => { diff --git a/ghcrawler/routes/index.js b/ghcrawler/routes/index.js new file mode 100644 index 00000000..24ed370e --- /dev/null +++ b/ghcrawler/routes/index.js @@ -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 From 506fa2ad14e38890663edf19b06bdfc7cea0aeb6 Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Tue, 1 Oct 2024 10:43:57 +0100 Subject: [PATCH 2/8] Add app version to logger --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4d264077..036d83b8 100644 --- a/index.js +++ b/index.js @@ -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) From 7c43743cf0d4af866f91ba5770eb1d3d52d3af9f Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Tue, 1 Oct 2024 11:10:43 +0100 Subject: [PATCH 3/8] point to branch of deploy workflow to test --- .github/workflows/build-and-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index b10cbfc3..7ff5cc76 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -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@53af332301d9a2f47cc62769c9b86f3460b79270 secrets: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }} From 9ca70dde442ccac347142f22b0aaea820d8bf46d Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Tue, 1 Oct 2024 11:43:33 +0100 Subject: [PATCH 4/8] Update action branch --- .github/workflows/build-and-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index 7ff5cc76..22e30caa 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -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@53af332301d9a2f47cc62769c9b86f3460b79270 + uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@c9a3c6b53dbc46d763b1ce322e7076c05c0f3238 secrets: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }} From 7155482bff6c3583723785e6dd0c394485672814 Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Tue, 1 Oct 2024 11:51:50 +0100 Subject: [PATCH 5/8] Update workflow branch --- .github/workflows/build-and-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index 22e30caa..6deda7b0 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -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@c9a3c6b53dbc46d763b1ce322e7076c05c0f3238 + uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@0a6c260 secrets: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }} From a4f31b43ebc4342399bac6f93b1412c35ce633ee Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Tue, 1 Oct 2024 11:55:24 +0100 Subject: [PATCH 6/8] Full branch needed --- .github/workflows/build-and-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index 6deda7b0..cd983f43 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -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@0a6c260 + uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@0a6c2607470e2e0e49bf2d6636223bcd62c1a7f8 secrets: AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }} From 79fc2351d444894a7d0a0b1f7d5e868b28db17be Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Thu, 3 Oct 2024 18:10:52 +0100 Subject: [PATCH 7/8] Update to current release of workflow --- .github/workflows/build-and-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index cd983f43..832dd1f6 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -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@0a6c2607470e2e0e49bf2d6636223bcd62c1a7f8 + 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 }} From 99cb4a3852ba30ef59e1e5775471e1adf943210c Mon Sep 17 00:00:00 2001 From: Lewis Jones Date: Thu, 3 Oct 2024 18:22:22 +0100 Subject: [PATCH 8/8] Remove build numbder APP_VERSION replaces it --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86ca915e..fba4b527 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,6 @@ FROM node:18-bullseye ENV APPDIR=/opt/service # Set environment variables from build arguments -ARG BUILD_NUMBER=0 -ENV BUILD_NUMBER=$APP_VERSION ARG APP_VERSION="UNKNOWN" ENV APP_VERSION=$APP_VERSION ARG BUILD_SHA="UNKNOWN"