CircleCI-Public / trigger-circleci-pipeline-action

Trigger a CircleCI pipeline from any GitHub Actions event.
https://github.com/marketplace/actions/trigger-circleci-pipeline
47 stars 43 forks source link

feat(outputs): set pipeline POST response data as GitHub Action outputs #47

Closed whatisdot closed 1 year ago

whatisdot commented 1 year ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

What issues are resolved by this PR?

Describe the new behavior.

Implements the description outlined in #28 to add Outputs to the GitHub Action in order to enable downstream projects to pull the pipeline number and id.

Example GitHub Job Steps

      - name: Deploying to ${{ inputs.environment_name }} with CircleCI Pipeline
        id: cci_pipeline
        uses:  snapsheet/trigger-circleci-pipeline-action@add_pipeline_request_outputs
        with:
          GHA_Data: ${{ toJSON(inputs) }}
          GHA_Meta: ${{ inputs.environment_name }}
          CCI_Context: ${{ fromJson(steps.environment_config.outputs.json_string).context }}
        env:
          CCI_TOKEN: ${{ secrets.CCI_TOKEN }}
          CCI_HOST: circleci.com # ...now required...?

      - name: Check CircleCI Outputs
        run: |
          echo "id: ${{ steps.cci_pipeline.outputs.id }}"
          echo "state: ${{ steps.cci_pipeline.outputs.state }}"
          echo "created_at: ${{ steps.cci_pipeline.outputs.created_at }}"
          echo "number: ${{ steps.cci_pipeline.outputs.number }}"

You should now see the outputs in your run logs:

Successfully triggered CircleCI Pipeline Run echo "id: 0f1c3884-fa98-4b9d-a95d-b473dd398cf1" id: 0f1c3884-fa98-4b9d-a95d-b473dd398cf1 state: pending created_at: 2023-03-22T19:08:10.214Z number: 1298

Does this PR introduce a breaking change?