Skip to content

Unique step ids in included plans? #31

@asford

Description

@asford

Wow. This project is amazing. 👏 👏 👏

Is is possible to include unique step ids in the expanded plan, so that step outputs in includes: template?

As a motivating example... https://github.com/peter-evans/create-or-update-comment recommends a two-step workflow to find and update a PR comment:

    - name: Find Comment
      uses: peter-evans/find-comment@v1
      id: fc
      with:
        issue-number: ${{ github.event.pull_request.number }}
        comment-author: 'github-actions[bot]'
        body-includes: Build output

    - name: Create or update comment
      uses: peter-evans/create-or-update-comment@v1
      with:
        comment-id: ${{ steps.fc.outputs.comment-id }}
        issue-number: ${{ github.event.pull_request.number }}
        body: |
          Build output
          ${{ steps.build.outputs.build-log }}
        edit-mode: replace

Here steps.fc.outputs.commend-id and steps.id.outputs.build-log are used in template expansions to pass step outputs into the resulting comment. This would be an ideal application of actions-includes, because you may want to run a few templated actions each outputting a different comment. This is a bit hard though, because you don't have access to unique ids per step.

I've done a workaround, where each unique required step is a different input variable of the form:

name: build
description: Build target and post comment.
inputs:
  target:
    required: True
  build-id:
    required: True
  comment-id:
    required: True
runs:
  using: "includes"
  steps:
    - id: ${{ inputs.build-id }}
      run: build ${{ inputs.target }}
    - id: ${{inputs.comment-id}}
      uses: peter-evans/find-comment@v1
      with:
        issue-number: ${{ github.event.pull_request.number }}
        comment-author: 'github-actions[bot]'
        body-includes: Build output ${{ inputs.target }}

    - uses: peter-evans/create-or-update-comment@v1
      with:
        comment-id: ${{ steps[inputs.comment-id].outputs.comment-id }}
        issue-number: ${{ github.event.pull_request.number }}
        body: |
          Build output ${{ inputs.target }}
          ${{ steps[inputs.build-id].outputs.stdout }}
        edit-mode: replace

However this feels a little clunky as the includer needs to specify a bunch of unique step ids like:

jobs:
  build:
    - name: base
      includes: /build
      with:
        target: base
        build-id: build-base
        comment-id: build-base
    - name: app
      includes: /build
      with:
        target: app
        build-id: build-app
        comment-id: build-app
    - name: app2
      includes: /build
      with:
        target: app2
        build-id: build-app2
        comment-id: build-app2

Not too crazy, but am I missing some logic that would allow me to express these unique ids and access their outputs in the expanded workflow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions