Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/update-jaeger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update Jaeger dependencies

on:
repository_dispatch:
types: [update-jaeger]

jobs:
update-jaeger:
runs-on: ubuntu-latest
env:
BRANCH_NAME: update-jaeger
DEPENDENCIES_FILENAME: dependencies.json
JAEGER_DIFF_FILENAME: dependencies.diff
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.CONTENTS_WRITE_PAT }}

- name: Update dependencies.json
run: |
echo ${{ toJson(github.event.client_payload) }} > dependencies.diff.json
npm run update-jaeger

- name: Commit, push changes and create PR
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b ${{ env.BRANCH_NAME }}
git add dependencies.json
git commit -m "Update Jaeger dependencies"
git push origin ${{ env.BRANCH_NAME }}
gh pr create -t "Update Jaeger dependencies" -B main -H ${{ env.BRANCH_NAME }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"storybook": "storybook dev -p 6006",
"start": "npm run storybook",
"build-storybook": "storybook build",
"download-jaeger-ui": "node --experimental-transform-types ./download-jaeger-ui.mts --output jaeger-ui",
"download-jaeger-ui": "node --experimental-transform-types ./scripts/download-jaeger-ui.mts --output jaeger-ui",
"update-jaeger": "node --experimental-transform-types ./scripts/update-jaeger.mts",
"prebuild": "rimraf dist && npm run download-jaeger-ui",
"build:dev": "npm run prebuild && webpack --progress --config webpack.dev.ts",
"build:dev:jetbrains": "npm run build:dev --env platform=JetBrains",
Expand Down
2 changes: 1 addition & 1 deletion download-jaeger-ui.mts → scripts/download-jaeger-ui.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Octokit } from "@octokit/rest";
import AdmZip from "adm-zip";
import fs from "fs";
import path from "path";
import dependenciesJson from "./dependencies.json" assert { type: "json" };
import dependenciesJson from "../dependencies.json" assert { type: "json" };

interface DependenciesJson {
jetBrainsPluginVersion: string;
Expand Down
35 changes: 35 additions & 0 deletions scripts/update-jaeger.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as fs from "fs/promises";
import * as path from "path";

type Dependencies = Record<string, string>;

const isDependencies = (object: unknown): object is Dependencies =>
typeof object === "object" &&
object !== null &&
!Array.isArray(object) &&
Object.values(object).every((value) => typeof value === "string");

const readDependencyFile = async (path: string): Promise<Dependencies> => {
const file = await fs.readFile(path, "utf-8");
const dependenciesObject = JSON.parse(file) as unknown;

if (!isDependencies(dependenciesObject)) {
throw new Error(`Invalid format in ${path}`);
}

return dependenciesObject;
};

const dependenciesFilePath = path.resolve("./dependencies.json");
const dependencies = await readDependencyFile(dependenciesFilePath);

const dependenciesDiffFilePath = path.resolve("./dependencies.diff.json");
const dependenciesDiff = await readDependencyFile(dependenciesDiffFilePath);

const mergedDependencies = { ...dependencies, ...dependenciesDiff };

await fs.writeFile(
dependenciesFilePath,
JSON.stringify(mergedDependencies, null, 2),
"utf-8"
);
Loading