-
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.
Initial port from ts-actions repo (#1)
* Initial port from ts-actions repo * add test geometry * update install cli version * tweak branding and readme * use latest install cli action
- Loading branch information
Showing
5 changed files
with
8,828 additions
and
2 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,34 @@ | ||
name: "test converting directory" | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test-convert-directory-action: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./ | ||
id: convert-dir | ||
with: | ||
kittycad-token: ${{ secrets.KITTYCAD_API_TOKEN }} | ||
input-directory: test-files | ||
output-directory: test-files-out | ||
conversion-type: fbx | ||
- name: check-files-converted | ||
run: | | ||
ls test-files-out | ||
all_exist () { | ||
local filename | ||
for filename; do | ||
test -f "$filename" && continue | ||
echo "$0: $filename does not exist - aborting" >&2 | ||
return 1 | ||
done | ||
return 0 | ||
} | ||
all_exist test-files-out/test-obj.fbx test-files-out/test-stl.fbx && echo "$0: all files exist" >&2 | ||
shell: bash |
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 |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# convert-directory | ||
Action for converting 3D files in a directory | ||
# Convert all files in a directory | ||
|
||
This action will convert all 3D files in a directory to your desired format. | ||
You will need to generate a `KITTYCAD_API_TOKEN` [here](https://kittycad.io/account) and add it to your repo's secrets | ||
|
||
Example usage: | ||
```yml | ||
name: Convert files | ||
on: | ||
pull_request: | ||
jobs: | ||
test-convert-directory-action: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: KittyCAD/ts-actions/[email protected] | ||
with: | ||
kittycad-token: ${{ secrets.KITTYCAD_API_TOKEN }} | ||
input-directory: original-files-path | ||
output-directory: converted-files-path | ||
conversion-type: fbx | ||
- name: Check files converted | ||
run: ls converted-files-path # prints converted file names | ||
``` |
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,42 @@ | ||
name: Convert 3D files directory with KittyCAD | ||
description: Convert all 3D files in a given directory to your desired output | ||
branding: | ||
icon: box | ||
color: gray-dark | ||
|
||
inputs: | ||
kittycad-token: | ||
required: true | ||
description: 'KittyCAD API TOKEN, generated at https://kittycad.io/account' | ||
input-directory: | ||
required: true | ||
description: 'folder containing files to be converted, allowed files are dae, fbx, obj, step and stl' | ||
output-directory: | ||
required: true | ||
description: 'folder where converted files will be put' | ||
conversion-type: | ||
required: true | ||
description: 'options are dae, fbx, fbxb, obj, step and stl' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: KittyCAD/[email protected] | ||
- name: convert files | ||
id: convert-files | ||
run: | | ||
mkdir -p "${{ inputs.output-directory }}" | ||
FILES_TO_CONVERT=$(find ${{ inputs.input-directory }} -type f \( -name "*.dae" -o -name "*.fbx" -o -name "*.obj" -o -name "*.step" -o -name "*.stl" \)) | ||
echo "converting:\n$FILES_TO_CONVERT\n" | ||
for FILE in ${FILES_TO_CONVERT[@]} | ||
do | ||
BASENAME=$(basename $FILE) | ||
RESULT=$(kittycad file convert $FILE "${{ inputs.output-directory }}/${BASENAME%.*}.${{ inputs.conversion-type }}") | ||
echo "$RESULT\n" | ||
done | ||
echo "Done converting files!" | ||
shell: bash | ||
env: | ||
KITTYCAD_API_TOKEN: ${{ inputs.kittycad-token }} |
Oops, something went wrong.