Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#472): ✨ define output #473

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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