From 80887ec86b2ffe7dfdcdc72df24aacfede5fb942 Mon Sep 17 00:00:00 2001 From: Shakar Bakr <5h4k4r.b4kr@gmail.com> Date: Sun, 3 Mar 2024 14:05:48 +0300 Subject: [PATCH] Add JSON output and extraction using jq Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com> --- action.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/action.yml b/action.yml index ac80e27..e010edc 100644 --- a/action.yml +++ b/action.yml @@ -43,6 +43,26 @@ runs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Run a command and output JSON + id: run-command + shell: bash + run: | + echo '{"tags": ["tag1", "tag2", "tag3"]}' > output.json + + - name: Display JSON + run: cat output.json + shell: bash + + - name: Extract specific value from JSON using jq + id: extract-json + run: echo "::set-output name=tag::$(echo '${{ steps.run-command.outputs.json }}' | jq -r '.tags[0]')" + shell: bash + + - name: Display Extracted Value + run: | + echo "Extracted Tag: ${{ steps.extract-json.outputs.tag }}" + shell: bash + - id: meta name: Extract Metadata uses: docker/metadata-action@v5