How to dynamically find/replace string value in file path, and use path as output arg in Github Action?

41 Views Asked by At

We have a GHA that is doing some C4 diagram generation on pushes, and works fine other than trying to drop the .png files into a similar folder structure elsewhere.

This is the core bit of the action that is most relevant:

      - name: Get all changes files
        id: get-changed-files
        uses: jitterbit/get-changed-files@v1

      - name: Get changed UML files
        id: get-changed-uml-files
        run: |
          puml_files=''
          for changed_file in ${{ steps.get-changed-files.outputs.modified }}; do
            extension="${changed_file##*.}"

            if [ "${extension}" == "puml" ]; then
              # add puml file
              puml_files="${puml_files} ${changed_file}"
              echo "Added file: ${changed_file}"
            fi
          done
          echo "puml-files=${puml_files}" >> $GITHUB_OUTPUT

      - name: Generate C4-PlantUML PNG Diagrams
        uses: dreamsinbits/export-plantuml-action@v1
        with:
          args: -v -o /github/workspace/docs/diagrams/diagram_images -tpng ${{ steps.get-changed-uml-files.outputs.puml-files }}

If the .puml file exists in docs/diagrams/diagram_code/group_a/something.puml as it stands now the image will be generated in docs/diagrams/diagram_images/something.png along with all other images. What I want is docs/diagrams/diagram_images/group_a/something.png).

Is there a reliable way to have the -o <path> adjust per .puml file?

0

There are 0 best solutions below