-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy GitHub Action workflow for CodeMap Generation
- Loading branch information
Sprungg
committed
Nov 18, 2024
1 parent
165f1d0
commit 390fc57
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |