From 390fc57380c80a6fe7495ca3e15fed54bc7f998c Mon Sep 17 00:00:00 2001 From: Sprungg Date: Mon, 18 Nov 2024 17:29:37 +0000 Subject: [PATCH] Deploy GitHub Action workflow for CodeMap Generation --- .github/workflows/generate_code_map.yml | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/generate_code_map.yml diff --git a/.github/workflows/generate_code_map.yml b/.github/workflows/generate_code_map.yml new file mode 100644 index 0000000..8c9fb84 --- /dev/null +++ b/.github/workflows/generate_code_map.yml @@ -0,0 +1,61 @@ +name: Generate and Deploy Codemap + +on: + push: + branches: + - main + - master + - develop + - feature/* # THIS SHOULD BE ELEGANTLY HANDLED IN THE CODEBASE LATER + workflow_dispatch: # Allows manual triggering of the workflow + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + # Step 1: Check out the repository + - name: Checkout Repository + uses: actions/checkout@v2 + + # Step 2: Set up Node.js + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + # Step 3: Install the sprungg-code-mapper package + - name: Install sprungg-code-mapper + run: | + npm install @sprungg/code-mapper + + # Step 4: Generate Codemap data using sprungg-code-mapper CLI + - name: Generate Codemap Data + run: | + # Generate data and save it to mapper-output.json + npx @sprungg/code-mapper . json mapper-output.json + + - name: Print JSON output for debugging + run: | + cat mapper-output.json + + - name: Deploy data to API + env: + SPRUNGG_API_URL: ${{ secrets.SPRUNGG_CODE_MAP_BASE_URL }} # Secure API URL + SPRUNGG_API_KEY: ${{ secrets.SPRUNGG_CODE_MAP_API_KEY }} # Secure API key for authentication + REPO_URL: ${{ secrets.SPRUNGG_CODE_MAP_REPO_URL }} # Repository URL for Sprungg reference + + run: | + # Prepare the JSON payload with properly quoted file content + json_content=$(cat mapper-output.json) + json_content=$(echo "$json_content" | jq -Rs '.') # Ensure json_content is a valid JSON string + echo "JSON Content: $json_content" + curl -X POST -H "Content-Type: application/json" \ + -H "Authorization: Bearer $SPRUNGG_API_KEY" \ + -d '{"repoUrl": "'"$REPO_URL"'", "codemapData": '"$json_content"'}' \ + "$SPRUNGG_API_URL" + + # Step 6: Clean up generated file + - name: Clean up generated files + run: | + rm -f mapper-output.json