add toJson #19
This file contains hidden or 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
| --- | |
| name: Test Loop | |
| on: | |
| push: | |
| branches: [development] | |
| jobs: | |
| # Job 1: Collect data | |
| define-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| colors: ${{ steps.colors.outputs.colores }} | |
| project-json: ${{ steps.json-project-step.outputs.json-project }} | |
| steps: | |
| - name: Define Colors | |
| id: colors | |
| run: | | |
| echo 'colores=["red", "green", "blue"]' >> "$GITHUB_OUTPUT" | |
| - name: Define JSON | |
| id: json-project-step | |
| run: | | |
| echo 'json-project={"count":4,"include":[{"project":"foo","config":"Debug"},{"project":"bar","config":"Release"}]}' >> "$GITHUB_OUTPUT" | |
| # echo 'json-project={"count":4,"include":[{"project":"foo","config":"Debug"}, \ | |
| # {"project":"bar","config":"Release"}]}' >> "$GITHUB_OUTPUT" | |
| # echo 'json-project=$( \ | |
| # {\"count\":4,\"include\":[{\"project\":\"foo\",\"config\":\"Debug\"}, \ | |
| # {\"project\":\"bar\",\"config\":\"Release\"}]} \ | |
| # )' >> "$GITHUB_OUTPUT" | |
| # echo "project-response=$(curl --insecure --request GET \ | |
| # --header 'authorization: Bearer ${{ secrets.authorization_token }}' \ | |
| # --header 'content-type: application/json' \ | |
| # --url ${{ vars.ansible_url }}projects/?scm_url=git%40git.bcbssc.com%3AInformationSystems%2Funix_platform_ansible.git \ | |
| # )" >> $GITHUB_OUTPUT | |
| ## Job 2: Print the output of the "define-matrix" job | |
| print-output: | |
| runs-on: ubuntu-latest | |
| needs: define-matrix | |
| steps: | |
| - name: Print colors variable | |
| run: | | |
| echo ${{ needs.define-matrix.outputs.colors }} | |
| - name: Print project-json variable | |
| run: | | |
| echo ${{ toJson(needs.define-matrix.outputs.project-json) }} | |
| # # job 2.1 | |
| # print-output-2: | |
| # # runs-on: ubuntu-latest | |
| # needs: define-matrix | |
| # runs-on: ${{ needs.define-matrix.outputs.project-json }} | |
| # steps: | |
| # - name: Log JSON file | |
| # run: echo "${{needs.define-matrix.outputs.project-json }}" | |
| # Job 3: Display data using "run" and "with" | |
| # produce-artifacts: | |
| # runs-on: ubuntu-latest | |
| # needs: define-matrix | |
| # strategy: | |
| # matrix: | |
| # color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} | |
| # steps: | |
| # - name: Define Color | |
| # env: | |
| # color: ${{ matrix.color }} | |
| # run: | | |
| # echo "$color" > color | |
| # - name: Produce Artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: ${{ matrix.color }} | |
| # path: color | |
| # - run: mkdir -p path/to/artifact | |
| # - run: echo hello > path/to/artifact/world.txt | |
| # - uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: my-artifact | |
| # path: path/to/artifact/world.txt | |
| # Job 4: Display data another way | |
| # consume-artifacts: | |
| # runs-on: ubuntu-latest | |
| # needs: | |
| # - define-matrix | |
| # - produce-artifacts | |
| # strategy: | |
| # matrix: | |
| # color: ${{ fromJSON(needs.define-matrix.outputs.colors) }} | |
| # steps: | |
| # - name: Retrieve Artifact | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: ${{ matrix.color }} | |
| # - name: Report Color | |
| # run: | | |
| # cat color |