Skip to content

Commit

Permalink
feat(#472): ✨ define output (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasAugustin authored Feb 29, 2024
1 parent 61bdae3 commit a19cd8d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Test action step
id: test
uses: ./ # Uses an action in the root directory
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: AndreasAugustin/template.git
is_dry_run: true
- name: print output
env:
FORMER_OUTPUT_PR_BRANCH: ${{ steps.test.outputs.pr_branch }}
run: echo "pr_branch ${FORMER_OUTPUT_PR_BRANCH}"
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # <owner/repo>, should be within secrets
```

### Configuration parameters
### Action Inputs

| Variable | Description | Required | `[Default]` |
|-----------------------------|---------------------------------------------------------------------------------------------------------------|----------|-----------------------------------------------------------------------|
Expand All @@ -254,6 +254,14 @@ jobs:
| git_remote_pull_params | `[optional]` set remote pull parameters | `false` | `--allow-unrelated-histories --squash --strategy=recursive -X theirs` |
| gpg_private_key | `[optional]` set if you want to sign commits | `false` | |

### Action Outputs

> Properties that are available after the action executed.

| output | description |
| ------ | ----------- |
| pr_branch | The name of the branch used for the pull request |

### Docker

There are docker images available. Please checkout [How to use docker](docs/DOCKER.md) for details.
Expand Down
13 changes: 13 additions & 0 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,16 @@ else
fi

echo "::endgroup::"

function set_github_action_outputs() {
echo "::group::set gh action outputs"
if [[ -z "${GITHUB_RUN_ID}" ]]; then
info "env var 'GITHUB_RUN_ID' is empty -> no github action workflow"
else
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
echo "pr_branch=${NEW_BRANCH}" >> "$GITHUB_OUTPUT"
fi
echo "::endgroup::"
}

set_github_action_outputs

0 comments on commit a19cd8d

Please sign in to comment.