Skip to content

feat: add token input and use default username constant - #95

Merged
chawyehsu merged 1 commit into
ScoopInstaller:mainfrom
chawyehsu:push-vrtrwozysvxn
Aug 22, 2026
Merged

feat: add token input and use default username constant#95
chawyehsu merged 1 commit into
ScoopInstaller:mainfrom
chawyehsu:push-vrtrwozysvxn

Conversation

@chawyehsu

Copy link
Copy Markdown
Member

With this change, downstreams don't have to explicitly set the GITHUB_TOKEN env when referencing the action.

before:

      - name: PullRequestHandler
        uses: ScoopInstaller/GithubActions@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required

after:

      - name: PullRequestHandler
        uses: ScoopInstaller/GithubActions@main

Existing explicitly defined GITHUB_TOKEN env still have the highest precedence (step level).

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added purple branding for the package.
    • Added an optional authentication token setting that defaults to the platform’s standard token.
    • Improved automated commit author configuration when no username is provided, using the standard bot identity.
  • Documentation
    • Updated workflow examples to reflect that explicitly providing an authentication token is optional.
    • Clarified the default token behavior in the environment-variable documentation.

Walkthrough

Changes

Action configuration

Layer / File(s) Summary
Token input and PowerShell wiring
action.yml, README.md
The action adds purple branding and an optional github_token input. The resolved value passes to the PowerShell step through GITHUB_TOKEN. Workflow examples and environment-variable documentation use the optional token configuration.
Shared Git username default
src/Variables.psm1, src/Helpers.psm1
The module exports DEFAULT_USERNAME. Initialize-NeededConfiguration uses this variable when USER_NAME is unset.

Merge Risk: ⚪ Minimal · up to 3ed3a

The PR adds token fallback behavior, but the generic README example still shows the old required environment variable and omits the new input and precedence rules. This is a minor documentation inconsistency; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: adding a token input and using a default username constant.
Description check ✅ Passed The description accurately explains the optional GITHUB_TOKEN input and the precedence of explicitly defined step-level values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 184a8588-59b0-48d8-b6f5-402086207391

📥 Commits

Reviewing files that changed from the base of the PR and between 3175e60 and 6859530.

📒 Files selected for processing (3)
  • action.yml
  • src/Helpers.psm1
  • src/Variables.psm1

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread action.yml Outdated
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 579f9dcf-a1ef-47ef-802d-0e2e7c5d9c4a

📥 Commits

Reviewing files that changed from the base of the PR and between 6859530 and 3ed3ab0.

📒 Files selected for processing (2)
  • README.md
  • action.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread README.md
Comment on lines 161 to +165
```yaml
- uses: ScoopInstaller/GithubActions@main
env:
# `GITHUB_TOKEN`: **REQUIRED**
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# `GITHUB_TOKEN`: Optional, `${{ github.token }}` if not specified
GITHUB_TOKEN: ${{ github.token }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- candidate files ---'
git ls-files | rg '(^|/)(README\.md|action\.ya?ml|package\.json|src|lib|test|tests|__tests__)(/|$)|github_token|GITHUB_TOKEN' | head -200

printf '%s\n' '--- README token references ---'
rg -n -C 4 'github_token|GITHUB_TOKEN|ScoopInstaller/GithubActions|Issues' README.md

printf '%s\n' '--- repository token references ---'
rg -n -C 3 'github_token|GITHUB_TOKEN' . -g '!README.md' -g '!node_modules' -g '!dist' -g '!build' | head -300

Repository: ScoopInstaller/GithubActions

Length of output: 5802


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- action.yml ---'
cat -n action.yml

printf '%s\n' '--- README.md lines 145-180 ---'
sed -n '145,180p' README.md

printf '%s\n' '--- input usage and workflow context ---'
rg -n -C 5 'inputs\.github_token|github_token:|env:|with:' README.md action.yml .github 2>/dev/null | head -300

Repository: ScoopInstaller/GithubActions

Length of output: 4378


🌐 Web query:

GitHub Actions documentation env context precedence step-level env versus action input and action.yml env expression

💡 Result:

In GitHub Actions, environment variable precedence follows a "most-specific-wins" model [1][2][3]. Variables defined at the step level override those at the job level, which in turn override those at the workflow level [1][2][3]. Regarding the specific interaction between step-level env and action inputs (with): 1. Action Inputs are not Environment Variables: Actions defined with uses (e.g., Docker or JavaScript actions) consume configuration primarily through the with keyword, not the step's env block [4]. The with inputs are mapped to environment variables by the runner using the format INPUT_<VARIABLE_NAME> (uppercase, with spaces replaced by underscores) [5]. 2. Step env is often ignored by uses actions: Defining an env block on a uses step does not configure the action unless that specific action is explicitly documented to read those environment variables [4]. For most actions, passing a value via env on the step will have no effect on the action's behavior; you must use with for declared inputs [4]. 3. Composite Actions: In composite actions, inputs are not automatically exposed as INPUT_* environment variables [5]. They must be accessed via the inputs context (e.g., ${{ inputs.name }}) within the composite action's steps [5][6]. If you want to use them as environment variables within the composite action, you must explicitly map them in the composite action's steps[*].env configuration [6]. When using expressions in action.yml (such as in env or with blocks), these are evaluated by the GitHub Actions runner before the job is sent to the runner. Consequently, they can access context data (like env, github, or inputs) but cannot access shell-based environment variables that are only created on the runner during execution [7]. Top results: [1], [5], [4], [2], [3]

Citations:


🌐 Web query:

site:docs.github.com GitHub Actions composite action caller env context action.yml steps env uses step environment variables

💡 Result:

In GitHub Actions composite actions, environment variables are handled differently than in standard workflow steps [1]. Notably, composite actions do not automatically receive environment variables created from workflow inputs (i.e., they do not automatically get INPUT_<VARIABLE_NAME>) [1]. To use environment variables within a composite action, you must explicitly map them using the env key within the steps configuration in your action.yml file [1]. Here is how you handle environment variables in composite actions: 1. Mapping Inputs: Since composite actions do not automatically expose inputs as environment variables, you must map them manually if your scripts require them [1][2]. You can do this by defining them in the env block of a step [2]: steps: - name: Example Step run: echo "Hello $MY_INPUT" shell: bash env: MY_INPUT: ${{ inputs.some-input-name }} 2. Accessing Contexts: You can use the env context (e.g., ${{ env.VAR_NAME }}) to reference custom variables defined in your workflow [3][4]. If you need to access GitHub-specific information, you can use the github context, such as ${{ github.action_path }} [5][2]. 3. Scope and Overrides: When defining env within a step in a composite action, these variables are scoped specifically to that step [1]. If you need to persist a variable change for subsequent steps within the same composite action (or the calling workflow), you must append the variable to the $GITHUB_ENV file [1]: run: echo "MY_VAR=value" >> $GITHUB_ENV Key considerations: - Contexts like env and github are processed by GitHub Actions, whereas runner environment variables (like $MY_VAR) are interpolated by the shell executing the script [6][4]. - Secrets are not automatically available to composite actions for security reasons [5]. You must pass them explicitly as inputs to the composite action [5]. - Composite actions do not share the full environment variable set of the caller workflow automatically; ensure all required variables are passed via inputs or environment mappings [7][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- all workflow and action metadata files ---'
git ls-files | rg '(^|/)(action\.ya?ml|workflow.*\.ya?ml|.*\.ya?ml)$' | while read -r f; do
  printf '%s\n' "--- $f"
  rg -n -C 3 'uses:.*GithubActions|github_token|GITHUB_TOKEN|env:|with:' "$f" || true
done

printf '%s\n' '--- concise repository history for relevant files ---'
git log --oneline -8 -- README.md action.yml

Repository: ScoopInstaller/GithubActions

Length of output: 2626


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

action = Path("action.yml").read_text()
readme = Path("README.md").read_text()

input_declared = bool(re.search(r"(?m)^  github_token:\s*$", action))
mapping = re.search(
    r"(?m)^\s*GITHUB_TOKEN:\s*\$\{\{\s*([^}]+?)\s*\}\}\s*$", action
)
readme_has_input = bool(re.search(r"(?m)^\s*github_token\s*:", readme))
readme_has_default_env = bool(re.search(
    r"(?m)^\s*GITHUB_TOKEN:\s*\$\{\{\s*github\.token\s*\}\}\s*$", readme
))

print(f"action input declared: {input_declared}")
print(f"action token mapping: {mapping.group(1).strip() if mapping else None}")
print(f"README documents github_token: {readme_has_input}")
print(f"README sets default GITHUB_TOKEN: {readme_has_default_env}")

assert input_declared
assert mapping
precedence = [part.strip() for part in mapping.group(1).split("||")]
assert precedence == ["env.GITHUB_TOKEN", "inputs.github_token", "github.token"]
assert not readme_has_input
assert readme_has_default_env
PY

printf '%s\n' '--- token-input commit summary ---'
git show --stat --oneline --no-renames 3ed3ab0

printf '%s\n' '--- token-input commit changes in public metadata and README ---'
git show --format= --no-ext-diff --no-renames 3ed3ab0 -- action.yml README.md

Repository: ScoopInstaller/GithubActions

Length of output: 3201


Document github_token without setting GITHUB_TOKEN in the generic example.

action.yml resolves tokens in this order: env.GITHUB_TOKEN, inputs.github_token, then github.token. Remove the default GITHUB_TOKEN assignment from this block. Add a separate with: github_token: example and document this precedence.

Source: MCP tools

@chawyehsu
chawyehsu merged commit 3a5a517 into ScoopInstaller:main Aug 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant