Skip to content

Update test-loop.yml #56

Update test-loop.yml

Update test-loop.yml #56

Workflow file for this run

---
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-string: ${{ steps.project-string-step.outputs.json-project-string }}
project-json: ${{ steps.project-string-step.outputs.json-project }}
steps:
- name: Define Colors
id: colors
run: |
echo 'colores=["red", "green", "blue"]' >> "$GITHUB_OUTPUT"
- name: Define Project String
id: project-string-step
run: |
echo 'json-project-string={"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 '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
# - name: Define JSON
# id: json-project-step
# run: |
# echo '
## Job 2: Print the output of the "define-matrix" job
print-output:
runs-on: ubuntu-latest
needs: define-matrix
outputs:
astring: ${{ steps.build-stuff.outputs.astring }}
# strategy:
# matrix: ${{ fromJSON(toJson(needs.define-matrix.outputs.project-string).include) }}
steps:
# - name: Print colors variable
# run: |
# echo ${{ needs.define-matrix.outputs.colors }}
# - name: Build project
# run: echo "Building project ${{ matrix.project }} with config ${{ matrix.config }}"
- name: Build project
id: build-stuff
run: |
echo 'astring=${{ fromJson(needs.define-matrix.outputs.project-string).include }}' >> "$GITHUB_OUTPUT"
- name: Print project-json variable
id: print-stuff
run: |
echo ${{ toJson(needs.define-matrix.outputs.project-string) }}
echo ${{ toJson(needs.define-matrix.outputs.project-string) }} | jq -r '.include[].project'
# echo "my_output=${{ toJson(needs.define-matrix.outputs.project-string) }} | jq -r '.include[].project'" >> "$GITHUB_OUTPUT"
# my_output=${{ toJson(needs.define-matrix.outputs.project-string) }} | jq -r '.include[].project'
# echo "::set-output name=the_output::$my_output"
# echo "includes:" $(echo $COUNT) }}
# echo "projects:" $(echo $COUNT | jq -r 'include[].project')
# env:
# COUNT: ${{ toJson(needs.define-matrix.outputs.project-string) }}
- name: Print more stuff
run: echo ${{ steps.print-stuff.outputs.my_output }}
print-output-2:
runs-on: ubuntu-latest
needs: print-output
# strategy:
# matrix:
# value: ${{ fromJson(needs.print-output.outputs.astring) }}
steps:
- name: Print project-string variable
run: |
echo ${{ toJson(needs.print-output.outputs.astring) }}
# echo "${{ toJson(matrix.value) }}"
# echo "The outputs are ${{ toJson(needs.define-matrix.outputs.project-string) }}"
# echo
# jobjson=$(echo "${{ toJson(needs.define-matrix.outputs) }}" )
# echo $jobjson | yq
# echo
# echo "colors is $(echo $jobjson | yq .colors)"
# # 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