Skip to content

Commit

Permalink
Initial port from ts-actions repo (#1)
Browse files Browse the repository at this point in the history
* 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
Irev-Dev committed Jun 6, 2022
1 parent 58a89a1 commit 4315f13
Show file tree
Hide file tree
Showing 5 changed files with 8,828 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/convert-directory-test.yml
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
26 changes: 24 additions & 2 deletions README.md
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
```
42 changes: 42 additions & 0 deletions action.yml
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 }}
Loading

0 comments on commit 4315f13

Please sign in to comment.