Skip to content

Commit

Permalink
issue #47: validate workflow behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
vivalareda committed Dec 12, 2023
1 parent fd03251 commit a5b4de5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/vercel-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@ name: Vercel Preview Deployment

on:
push:
branches:
- main
pull_request:

env:
TYPESCRIPT_VERSION: 0.1.1
FILE_PATH: "src/_version.ts"

jobs:
extract-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

lint-test:
uses: ai-cfia/github-workflows/.github/workflows/workflow-lint-test-node.yml@main
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

vercel-deployment-dev:
needs: lint-test
uses: ai-cfia/github-workflows/.github/workflows/workflow-vercel-deployment.yml@53-update-vercel-deployment-to-add-setup-node-step
with:
project-name: 'finesse-frontend'
deployment-environment: 'dev'
secrets: inherit
- name: Extract Version
id: extract_version
run: node ./scripts/extract-typescript-version.js

vercel-deployment-uat:
if: github.ref == 'refs/heads/main'
uses: ai-cfia/github-workflows/.github/workflows/workflow-vercel-deployment.yml@53-update-vercel-deployment-to-add-setup-node-step
with:
project-name: 'finesse-frontend'
deployment-environment: 'uat'
secrets: inherit
- name: Check Version
run: |
if [ "${{ steps.extract_version.outputs.version }}" != "${{ env.TYPESCRIPT_VERSION }}" ]; then
echo "You should be using typescript version ${EXPECTED_VERSION} instead of ${{ steps.extract_version.outputs.version }} ";
exit 1;
fi
18 changes: 18 additions & 0 deletions scripts/extract-typescript-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs');

const filePath = 'src/_version.ts';

fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}

const versionMatch = data.match(/version: '([^']+)'/);
if (versionMatch && versionMatch[1]) {
console.log("Extracted Version:", versionMatch[1]);
process.stdout.write(`::set-output name=version::${versionMatch[1]}`);
} else {
console.error('Version could not be extracted');
}
});
2 changes: 1 addition & 1 deletion src/_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface TsAppVersion {
gitTag?: string;
};
export const versions: TsAppVersion = {
version: '0.2.0',
version: '0.1.0',
name: 'finesse-frontend',
versionDate: '2023-12-04T21:25:19.734Z',
gitCommitHash: '1b203ac',
Expand Down

0 comments on commit a5b4de5

Please sign in to comment.