Skip to content

Instantly share code, notes, and snippets.

@brianjbayer
Last active April 22, 2023 14:50
Show Gist options
  • Select an option

  • Save brianjbayer/0e75d7d1ad5e5cfaf01b4b5ec34c946c to your computer and use it in GitHub Desktop.

Select an option

Save brianjbayer/0e75d7d1ad5e5cfaf01b4b5ec34c946c to your computer and use it in GitHub Desktop.

Example of Outputs in GitHub Actions

Called Job

  branch-and-last-commit:
    runs-on: ubuntu-latest
    outputs:
      branch-name: ${{ steps.getbranch.outputs.branchname }}

    steps:
      - uses: actions/checkout@v1
      - name: Get merged branch name from merge commit message
        id: getbranch
        run: echo "branchname=$(git log -1 --pretty=%B | grep 'Merge pull request' | sed 's/^[^/]*\///')" >> $GITHUB_OUTPUT

Caller Job

  branch-and-last-commit-merged-info:
    needs: [branch-and-last-commit]
    runs-on: ubuntu-latest
    env:
      env:
      GIT_REPO: ${{ github.repository }}
      BRANCH_LAST_COMMIT: ${{ needs.merged-branch-last-commit.outputs.branch-commit }}
      BRANCH: ${{ needs.merged-branch-name.outputs.branch-name }}

    steps:
      - uses: actions/checkout@v1

      - name: Merged branch
        run: echo "BRANCH= [${BRANCH}]"

      - name: Last commit of Merged branch
        run: echo "BRANCH_LAST_COMMIT= [${BRANCH_LAST_COMMIT}]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment