From 617e5359d7e2e2499482b581bb2af7c1b05b2280 Mon Sep 17 00:00:00 2001 From: Yoland Y <4950057+yoland68@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:07:56 -0700 Subject: [PATCH] Fix various parts for action yml file --- action.py | 2 +- action.yml | 50 +++++++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/action.py b/action.py index b68ac36..aad1741 100644 --- a/action.py +++ b/action.py @@ -121,7 +121,7 @@ def main(args): end_time = int(datetime.datetime.now().timestamp()) # TODO: add support for multiple file outputs - gs_path = f"output-files/{args.github_action_workflow_name}-{args.os}-{workflow_file_name}-run-${args.run_id}" + gs_path = f"output-files/{args.github_action_workflow_name}-{args.os}-{workflow_file_name}-run-{args.run_id}" upload_to_gcs( args.gsc_bucket_name, gs_path, diff --git a/action.yml b/action.yml index d5da2f5..6989644 100644 --- a/action.yml +++ b/action.yml @@ -84,6 +84,7 @@ runs: ############################################################ - name: '[Unix] Auth to GCS' uses: "google-github-actions/auth@v2" + if: ${{ inputs.os != 'windows' }} with: credentials_json: "${{ inputs.google_credentials }}" @@ -91,10 +92,8 @@ runs: uses: conda-incubator/setup-miniconda@v3 if: ${{ inputs.os != 'windows' }} with: - activate-environment: comfyui + activate-environment: gha-comfyui auto-activate-base: false - environment-file: ${{ inputs.conda_env_file }} - use-only-tar-bz2: true - name: '[Unix] Check conda environment' if: ${{ inputs.os != 'windows' }} @@ -103,21 +102,13 @@ runs: conda list shell: bash -el {0} - - name: '[Unix] Generate hash from models-json' + - name: '[Unix-Only] Generate hash from models-json' if: ${{ inputs.os != 'windows' }} id: generate_hash run: | echo "hash=$(echo '${{ inputs.models-json }}' | sha256sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT shell: bash - - name: '[Unix] Cache models' - if: ${{ inputs.os != 'windows' }} - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/models - key: ${{ runner.os }}-models-${{ steps.generate_hash.outputs.hash }} - save-always: true - - name: '[Unix] Download models' if: ${{ inputs.os != 'windows' }} shell: bash -el {0} @@ -125,11 +116,11 @@ runs: cd ${{ github.action_path }} python3 download-models.py raw '${{ inputs.models-json }}' "${{ github.workspace }}/models/" - - name: '[Unix] Run Python application in background' + - name: '[Unix] Run ComfyUI' if: ${{ inputs.os != 'windows' }} shell: bash -el {0} run: | - comfy launch -- --force-fp16 > application.log 2>&1 & + python3 main.py > application.log 2>&1 & - name: '[Unix] Check if the server is running' if: ${{ inputs.os != 'windows' }} @@ -153,7 +144,7 @@ runs: echo "commit_title=$MESSAGE" >> $GITHUB_OUTPUT echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT - - name: '[Unix] Queue Prompts' + - name: '[Unix] Run Python Action' id: unix_action if: ${{ inputs.os != 'windows' }} shell: bash -el {0} @@ -161,9 +152,16 @@ runs: cd ${{ github.action_path }} echo "Running workflows: ${{inputs.workflow_filenames}}" python3 action.py --comfy-workflow-names ${{ inputs.workflow_filenames }} --github-action-workflow-name "${{ github.workflow }}" --os "${{ inputs.os }}" --run-id "${{ github.run_id }}" --gsc-bucket-name "${{ inputs.gcs_bucket_name }}" --workspace-path "${{ github.workspace }}" --output-file-prefix ${{ inputs.output_prefix }} --repo "${{ github.repository }}" --commit-hash "${{ steps.unix_get_commit_details.outputs.commit_hash }}" --commit-time "${{ steps.unix_get_commit_details.outputs.commit_time }}" --commit-message "${{ steps.unix_get_commit_details.outputs.commit_title }}" --branch-name "${{ github.ref_name }}" --api-endpoint "${{ inputs.api_endpoint }}" + + - name: '[Unix] Upload Output Files' + uses: actions/upload-artifact@v4 + if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} + with: + name: output-files-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} + path: ${{ github.workspace }}/output/** - name: '[Unix] Upload log file' - if: ${{ inputs.os != 'windows' }} + if: ${{ inputs.os != 'windows' && ( success() || failure() ) }} uses: actions/upload-artifact@v4 with: name: app-logs-${{ github.job }}-${{ inputs.os }}-${{inputs.workflow_name}}-${{ github.run_id }} @@ -200,22 +198,28 @@ runs: ## ## ## ## ##################################################################################### + - name: '[Win] Auth to GCS' uses: "google-github-actions/auth@v2" + if: ${{ inputs.os == 'windows' }} with: credentials_json: "${{ inputs.google_credentials }}" - - name: '[Win-Only] Install Conda Env' + - name: '[Win] Setup Conda' + uses: conda-incubator/setup-miniconda@v3.0.3 if: ${{ inputs.os == 'windows' }} - shell: powershell - run: | - conda env update -f ${{ inputs.conda_env_file }} + with: + auto-update-conda: true + miniconda-version: latest + activate-environment: gha-comfyui + python-version: ${{ inputs.python_version }} + continue-on-error: true - name: "[Win] Check conda environment" if: ${{ inputs.os == 'windows' }} run: | - conda activate comfyui + conda activate gha-comfyui conda info conda list shell: powershell @@ -265,7 +269,7 @@ runs: # Write-Host "Running download-models.py with input: $jsonInputEscaped and output directory: $outputDir" # python download-models.py raw "$jsonInputEscaped" "$outputDir" - - name: '[Win] Run Python application' + - name: '[Win] Run ComfyUI' if: ${{ inputs.os == 'windows' }} shell: powershell run: | @@ -295,7 +299,7 @@ runs: "commit_title=$message" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append "commit_hash=$commit_hash" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append - - name: '[Windows] Queue Prompts' + - name: '[Windows] Run Python Action' id: windows_action if: ${{ inputs.os == 'windows' }} shell: powershell