From fdfdc055c11a6e7b832ceffdaffcb2a14eda696d Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 9 Sep 2024 14:21:00 -0500 Subject: [PATCH 1/4] feat(ci): push STEP files into public onshape document --- .github/workflows/linux-eic-shell.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 298438266..a9ef63324 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -319,6 +319,35 @@ jobs: name: ${{matrix.detector_config}}.stp path: ${{matrix.detector_config}}.stp if-no-files-found: error + - name: Upload to new public OnShape document + run: | + API=https://cad.onshape.com/api/v6 + CREDENTIALS=$(printf ${{secrets.ONSHAPE_ACCESS_KEY}}:${{secrets.ONSHAPE_SECRET_KEY}} | base64) + # Create new public document + curl -X POST $API/documents \ + -H "accept: application/json;charset=UTF-8; qs=0.09" \ + -H "Authorization: Basic $CREDENTIALS" \ + -H "Content-Type: application/json;charset=UTF-8; qs=0.09" \ + -d '{ "name": "'${{matrix.detector_config}}_${{github.run_id}}'", "isPublic": "true" }' \ + -o create.json + # Get document and workspace id + did=$(jq -r .id create.json) + wid=$(jq -r .defaultWorkspace.id create.json) + # Upload and translate STEP file + curl -X POST $API/translations/d/$did/w/$wid \ + -H "accept: application/json;charset=UTF-8; qs=0.09" \ + -H "Authorization: Basic $CREDENTIALS" \ + -H "Content-Type: multipart/form-data" \ + -F "formatName=" \ + -F "flattenAssemblies=true" \ + -F "translate=true" \ + -F "file=@${{matrix.detector_config}}.stp" \ + -o upload.json + # Check on upload + tid=$(jq -r .id upload.json) + curl -X GET $API/translations/$tid + # User access link + echo "https://cad.onshape.com/documents/$did/w/$wid" dump-constants: runs-on: ubuntu-latest From bc9e9fc8a32f143f9c514b252df8797fec989e45 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 9 Sep 2024 14:58:24 -0500 Subject: [PATCH 2/4] dbg: curl -v --- .github/workflows/linux-eic-shell.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index a9ef63324..68f3eeefd 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -324,7 +324,7 @@ jobs: API=https://cad.onshape.com/api/v6 CREDENTIALS=$(printf ${{secrets.ONSHAPE_ACCESS_KEY}}:${{secrets.ONSHAPE_SECRET_KEY}} | base64) # Create new public document - curl -X POST $API/documents \ + curl -v -X POST $API/documents \ -H "accept: application/json;charset=UTF-8; qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ -H "Content-Type: application/json;charset=UTF-8; qs=0.09" \ @@ -333,8 +333,10 @@ jobs: # Get document and workspace id did=$(jq -r .id create.json) wid=$(jq -r .defaultWorkspace.id create.json) + # User access link + echo "https://cad.onshape.com/documents/$did/w/$wid" # Upload and translate STEP file - curl -X POST $API/translations/d/$did/w/$wid \ + curl -v -X POST $API/translations/d/$did/w/$wid \ -H "accept: application/json;charset=UTF-8; qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ -H "Content-Type: multipart/form-data" \ @@ -346,8 +348,6 @@ jobs: # Check on upload tid=$(jq -r .id upload.json) curl -X GET $API/translations/$tid - # User access link - echo "https://cad.onshape.com/documents/$did/w/$wid" dump-constants: runs-on: ubuntu-latest From 8e47af02a1ece9a03ca9e6e0d0614430ba59a041 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 9 Sep 2024 15:14:14 -0500 Subject: [PATCH 3/4] fix: base64 --wrap=0 --- .github/workflows/linux-eic-shell.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 68f3eeefd..35fe9679c 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -322,9 +322,9 @@ jobs: - name: Upload to new public OnShape document run: | API=https://cad.onshape.com/api/v6 - CREDENTIALS=$(printf ${{secrets.ONSHAPE_ACCESS_KEY}}:${{secrets.ONSHAPE_SECRET_KEY}} | base64) + CREDENTIALS=$(printf ${{secrets.ONSHAPE_ACCESS_KEY}}:${{secrets.ONSHAPE_SECRET_KEY}} | base64 --wrap=0) # Create new public document - curl -v -X POST $API/documents \ + curl -X POST $API/documents \ -H "accept: application/json;charset=UTF-8; qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ -H "Content-Type: application/json;charset=UTF-8; qs=0.09" \ @@ -336,13 +336,14 @@ jobs: # User access link echo "https://cad.onshape.com/documents/$did/w/$wid" # Upload and translate STEP file - curl -v -X POST $API/translations/d/$did/w/$wid \ + curl -X POST $API/translations/d/$did/w/$wid \ -H "accept: application/json;charset=UTF-8; qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ -H "Content-Type: multipart/form-data" \ - -F "formatName=" \ + -F "formatName=STEP" \ -F "flattenAssemblies=true" \ -F "translate=true" \ + -F "yAxisIsUp=true" \ -F "file=@${{matrix.detector_config}}.stp" \ -o upload.json # Check on upload From 3fd7c1bbd4fd158f078af68ed78dfea5eb4dc7f2 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 9 Sep 2024 15:30:22 -0500 Subject: [PATCH 4/4] fix: curl authentication on get translations --- .github/workflows/linux-eic-shell.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 35fe9679c..43d44f875 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -325,9 +325,9 @@ jobs: CREDENTIALS=$(printf ${{secrets.ONSHAPE_ACCESS_KEY}}:${{secrets.ONSHAPE_SECRET_KEY}} | base64 --wrap=0) # Create new public document curl -X POST $API/documents \ - -H "accept: application/json;charset=UTF-8; qs=0.09" \ + -H "accept: application/json;charset=UTF-8;qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ - -H "Content-Type: application/json;charset=UTF-8; qs=0.09" \ + -H "Content-Type: application/json;charset=UTF-8;qs=0.09" \ -d '{ "name": "'${{matrix.detector_config}}_${{github.run_id}}'", "isPublic": "true" }' \ -o create.json # Get document and workspace id @@ -337,7 +337,7 @@ jobs: echo "https://cad.onshape.com/documents/$did/w/$wid" # Upload and translate STEP file curl -X POST $API/translations/d/$did/w/$wid \ - -H "accept: application/json;charset=UTF-8; qs=0.09" \ + -H "accept: application/json;charset=UTF-8;qs=0.09" \ -H "Authorization: Basic $CREDENTIALS" \ -H "Content-Type: multipart/form-data" \ -F "formatName=STEP" \ @@ -348,7 +348,9 @@ jobs: -o upload.json # Check on upload tid=$(jq -r .id upload.json) - curl -X GET $API/translations/$tid + curl -X GET $API/translations/$tid \ + -H "accept: application/json;charset=UTF-8;qs=0.09" \ + -H "Authorization: Basic $CREDENTIALS" dump-constants: runs-on: ubuntu-latest