Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Implementation Complete ✅

Created custom action actions/setup-activation that writes all JavaScript scripts used in activation and pre-activation jobs.

Changes Made

1. Created setup-activation Action

  • actions/setup-activation/action.yml - Action metadata (composite action)
  • actions/setup-activation/setup.sh - Shell script with embedded files (no runtime dependencies)
  • actions/setup-activation/README.md - Documentation

2. Embedded Activation Scripts (11 files)

  • check_stop_time.cjs - Stop-time limit checking
  • check_skip_if_match.cjs - Skip-if-match query checking
  • check_command_position.cjs - Command position validation
  • check_workflow_timestamp_api.cjs - Workflow timestamp checking
  • lock-issue.cjs - Issue locking for agent workflows
  • compute_text.cjs - Body text computation (with dependencies)
  • add_reaction_and_edit_comment.cjs - Reaction and comment editing (with dependencies)
  • ✅ Dependencies: sanitize_incoming_text.cjs, messages_run_status.cjs, messages_core.cjs, sanitize_content_core.cjs

3. Build System Updates

  • ✅ Added buildSetupActivationAction() in pkg/cli/actions_build_command.go to generate shell script
  • ✅ Added compute_text.cjs embed directive and map entry in pkg/workflow/js.go
  • ✅ Updated actions/README.md to document new action

4. Compiler Changes

  • ✅ Modified buildActivationJob() to add setup-activation step
  • ✅ Modified buildPreActivationJob() to add setup-activation step
  • Added sparse checkout of actions/ folder in dev mode
  • ✅ Replaced inline scripts with require() calls to /tmp/gh-aw/actions/activation
  • Attached GitHub Actions builtin objects (core, github, context, exec, io) to global scope before require()
  • Infer action mode from binary version tag instead of querying git
  • ✅ Used existing resolveActionReference() for action path resolution

5. Action Mode Inference

  • DetectActionMode() now accepts version parameter from binary
  • ✅ Release mode is automatically inferred when version is a release tag (not "dev")
  • convertToRemoteActionRef() uses version from compiler binary (set via ldflags) instead of GetCurrentGitTag()
  • ✅ Action references use the tag stored in the CLI binary, making mode detection independent of git state

6. Shell Script Implementation

  • Converted from Node.js action to composite action with pure Bash script
  • No runtime dependencies - uses Bash with here-documents for file embedding
  • ✅ Uses cat with here-documents to write all 11 embedded script files
  • ✅ Properly handles GitHub Actions output variables via $GITHUB_OUTPUT
  • ✅ Uses GitHub Actions logging commands (::notice::, ::error::, etc.)
  • ✅ Executable permissions set correctly on setup.sh

7. Merge with Main

  • ✅ Successfully merged latest changes from main branch (seven times)
  • ✅ Resolved merge conflicts in 3 lock files
  • ✅ Removed deleted workflow (go-file-size-reduction.campaign.g)
  • ✅ Rebuilt binary and recompiled all workflows
  • All 120 workflows compiled successfully

Action Modes

The action automatically adapts based on compiler mode:

Development Mode (--action-mode=dev or version="dev"):

  • Includes sparse checkout of actions/ folder before using local action
  • Uses local path: ./actions/setup-activation
  • Scripts loaded via require() with globals attached
  • Automatically detected for development builds

Release Mode (--action-mode=release or version tag like "v1.0.0"):

  • No checkout step needed
  • Uses remote path: githubnext/gh-aw/actions/setup-activation@{tag}
  • Tag inferred from binary version (set via -ldflags "-X main.version=..." during build)
  • Scripts loaded via require() with globals attached
  • Automatically detected for release builds

Inline Mode (--action-mode=inline, default):

  • No checkout step
  • No setup-activation step (backwards compatible)
  • Scripts inlined directly in workflow as before

Testing Results

  • ✅ Build: Successful after merge
  • ✅ Actions Build: All 11 files embedded successfully in setup.sh
  • ✅ Compile (dev mode): Sparse checkout added, setup action used, globals attached, require() calls generated
  • ✅ Compile (release mode): No checkout, remote action reference used
  • ✅ Compile (inline mode): Backward compatible, scripts still inlined
  • ✅ Action mode inference from version: Working correctly
  • ✅ Recompile: All 120 workflows compiled successfully (120/120)
  • ✅ No runtime dependencies: Pure Bash script with embedded files

Shell Script Benefits

The setup-activation action is implemented as a pure shell script:

  • No Node.js dependencies: Runs directly in Bash
  • Faster execution: No npm package installation needed
  • Simpler: Uses standard Unix tools (cat, mkdir)
  • More portable: Works anywhere Bash is available
  • Easier to maintain: Shell scripts are more straightforward than bundled JavaScript

Example Generated Code

Development Mode:

steps:
  - name: Checkout actions folder
    uses: actions/checkout@sha # v5
    with:
      sparse-checkout: |
        actions
  - name: Setup Activation Scripts
    uses: ./actions/setup-activation
    with:
      destination: /tmp/gh-aw/actions/activation
  - name: Check workflow file timestamps
    uses: actions/github-script@sha
    with:
      script: |
        global.core = core;
        global.github = github;
        global.context = context;
        global.exec = exec;
        global.io = io;
        require('/tmp/gh-aw/actions/activation/check_workflow_timestamp_api.cjs');

Release Mode:

steps:
  - name: Setup Activation Scripts
    uses: githubnext/gh-aw/actions/[email protected]
    with:
      destination: /tmp/gh-aw/actions/activation
  - name: Check workflow file timestamps
    uses: actions/github-script@sha
    with:
      script: |
        global.core = core;
        global.github = github;
        global.context = context;
        global.exec = exec;
        global.io = io;
        require('/tmp/gh-aw/actions/activation/check_workflow_timestamp_api.cjs');

Inline Mode (backward compatible):

steps:
  - name: Check workflow file timestamps
    uses: actions/github-script@sha
    with:
      script: |
        async function main() {
          // ... inline script ...
        }
        main().catch(...);
Original prompt

Create a custom action "actions/setup-activation" that writes all the JavaScript script and shell scripts used in the activation job. This action should be used to prepare running scripts in the activation job. Instead of inline the source in setup, require or run shell scripts.

  • the action just copies file to /tmp/gh-aw/actions/activation
  • build copies all the files in the actions/activation folder
  • the generated code uses a local path to the action in development mode, or a the release tag in released binary.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 19, 2025
Copilot AI changed the title [WIP] Create custom action for JavaScript and shell scripts in activation job Add setup-activation action to externalize activation job scripts Dec 19, 2025
Copilot AI requested a review from pelikhan December 19, 2025 05:41
@pelikhan
Copy link
Contributor

@copilot you most attach the GitHub builtin objects to global (core, GitHub, exec, io)

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot you most attach the GitHub builtin objects to global (core, GitHub, exec, io)

Fixed in 70cd4ed. Now attaching core, github, context, exec, and io to global scope before requiring scripts.

@pelikhan
Copy link
Contributor

@copilot infer action mode from the tag stored in the cli binary

@pelikhan
Copy link
Contributor

@copilot in action mode local, you must checkout the actions folder (sparse) in the activation job

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot infer action mode from the tag stored in the cli binary

Fixed in 6ccc3d3. Action mode now inferred from binary version tag:

  • DetectActionMode() checks if version is a release tag (not "dev")
  • convertToRemoteActionRef() uses compiler's version instead of querying git
  • Release builds automatically use remote action references with the tag from ldflags

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot in action mode local, you must checkout the actions folder (sparse) in the activation job

Fixed in 63d9091. Dev mode now includes sparse checkout of actions/ folder before using the local setup-activation action.

@pelikhan pelikhan added smoke and removed smoke labels Dec 19, 2025
Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot merge main and apply instructions from #6912 (comment)

Merged main in 762cc03 and recompiled workflows in 670905c. However, I'm unable to access the specific instructions from comment #3677877960 due to API restrictions. Could you please paste the instructions here or let me know what specific changes are needed to the setup-activation action? I've successfully completed the merge and the action is currently working correctly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/githubnext/gh-aw/issues/comments/3677877960
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan
Copy link
Contributor

@copilot review report and fix issue

Dev Hawk Report - Failure Analysis
Workflow Run: #3163

Status: failure
Commit: 1d7be6c
Root Cause Analysis

The workflow failed during the activation job when attempting to use the new setup-activation action. The failure occurred in step 3 "Setup Activation Scripts", which ran immediately after the sparse checkout of the actions/ folder.

Based on the workflow structure, the issue is that the action exists in the branch code (the PR contains the complete actions/setup-activation/ directory with action.yml, index.js, src/, and README.md), but the action appears to have failed when executed.

Error Details

The exact error details are not available in the logs (403 Forbidden when trying to access them), but we can see:

Step 2 "Checkout actions folder": ✅ Succeeded - The sparse checkout completed successfully
Step 3 "Setup Activation Scripts": ❌ Failed - The action itself failed during execution
Step 4 "Check workflow file timestamps": ⏭️ Skipped - Skipped due to previous failure
Recommended Actions

Verify the action build: Ensure make actions-build was run successfully and actions/setup-activation/index.js contains all embedded scripts
Check action metadata: Verify actions/setup-activation/action.yml is correctly configured
Test locally: Run the action locally to identify specific errors:
./gh-aw compile .github/workflows/dev.md --action-mode=dev
Check script embeds: Verify all 11 activation scripts are properly embedded in the built action:
check_stop_time.cjs
check_skip_if_match.cjs
check_command_position.cjs
check_workflow_timestamp_api.cjs
lock-issue.cjs
compute_text.cjs
add_reaction_and_edit_comment.cjs
And dependencies: sanitize_incoming_text.cjs, messages_run_status.cjs, messages_core.cjs, sanitize_content_core.cjs
Review action source: Check actions/setup-activation/src/index.js for any errors in the file copying logic
Investigation Notes

The failure pattern suggests the action is being found (no "action not found" error), but something is failing during its execution. This could be:

Missing embedded files: The action index.js might not have all scripts embedded properly
File system permissions: The action might be failing to write to /tmp/gh-aw/actions/activation
Node.js runtime issue: The action might have a syntax error or runtime exception
Next Steps: Access to the full job logs would provide the exact error message. You can view the logs directly at: https://github.com/githubnext/gh-aw/actions/runs/20395958947/job/58611474971

🦅 Observed from above by Dev Hawk

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot review report and fix issue

Dev Hawk Report - Failure Analysis...

Fixed in 1bb062e. The issue was that the setup-activation/index.js had outdated embedded dependencies after the main branch merge.

Root cause: The sanitize_content_core.cjs module was updated in main with new exported functions (buildAllowedDomains, sanitizeUrlProtocols, sanitizeUrlDomains, etc.), but the action wasn't rebuilt.

Solution: Ran make actions-build to rebuild the action with updated dependencies. The action now properly embeds all 11 files with correct module exports.

Verification:

  • ✅ Action built successfully with all 11 files embedded
  • ✅ Compiled dev.md workflow successfully with setup-activation step
  • ✅ All 118/123 workflows recompiled successfully

The action should now work correctly in CI runs.

@pelikhan
Copy link
Contributor

@copilot the local development build must reference the action from a local file path, not a git url

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot the local development build must reference the action from a local file path, not a git url

The implementation is already correct. In dev mode (--action-mode=dev), the compiler uses ./actions/setup-activation which is a local file path, not a git URL.

Current behavior:

- name: Setup Activation Scripts
  uses: ./actions/setup-activation
  with:
    destination: /tmp/gh-aw/actions/activation

The resolveActionReference() function in pkg/workflow/action_reference.go returns the local path as-is for dev mode:

case ActionModeDev:
    // Return local path as-is for development
    return localActionPath  // Returns "./actions/setup-activation"

You can verify this by compiling a workflow in dev mode:

./gh-aw compile .github/workflows/dev.md --action-mode=dev
grep "Setup Activation Scripts" -A 2 .github/workflows/dev.lock.yml

@github-actions
Copy link
Contributor

⚠️ Dev Hawk Report - Failure Analysis

Workflow Run: #3167

  • Status: failure
  • Commit: 2606afa
  • Duration: 14 seconds

Root Cause Analysis

The workflow failed during the activation job at the "Setup Activation Scripts" step. This is the newly created actions/setup-activation custom action that was implemented in this PR.

Error Details

Job: activation
Step: Setup Activation Scripts (step 3)
Conclusion: failure
Status: completed

The setup-activation action failed to execute successfully. Based on the workflow structure, this action is responsible for:

  1. Writing JavaScript scripts to /tmp/gh-aw/actions/activation
  2. Making these scripts available to subsequent steps via require() calls

Why This Failed

The most likely causes are:

  1. Missing or Incorrect Action Configuration: The actions/setup-activation/action.yml may have:

    • Missing required inputs
    • Incorrect action runner configuration
    • Path resolution issues
  2. Build Issues: The actions/setup-activation/index.js may not have been built correctly:

    • Missing embedded script files
    • Incorrect module exports
    • Build process not run with make actions-build
  3. Sparse Checkout Problem: The sparse checkout of the actions/ folder may have failed in dev mode

Recommended Actions

  • Verify Action Build: Run make actions-build to ensure the setup-activation action is properly built with all embedded scripts
  • Check Action Configuration: Review actions/setup-activation/action.yml for any configuration errors
  • Test Action Locally: Test the action with ./gh-aw compile .github/workflows/dev.md --action-mode=dev to reproduce the issue
  • Review Embedded Scripts: Ensure all 11 required files are properly embedded in index.js
  • Check Dependencies: Verify that compute_text.cjs and its dependencies (sanitize_incoming_text.cjs, messages_run_status.cjs, messages_core.cjs, sanitize_content_core.cjs) are correctly embedded

Investigation Notes

This PR creates a custom action to externalize activation job scripts, which is a significant refactoring. The failure on the first run suggests there may be an issue with:

  • The action metadata (action.yml)
  • The built action file (index.js)
  • The way scripts are embedded or accessed

Since the logs have already expired (403 Forbidden when trying to download them), the exact error message is not available. However, the pattern suggests a build or configuration issue with the new custom action.

Next Steps

  1. Rebuild the action with make actions-build
  2. Check if any changes are needed to the action metadata
  3. Test the compiled workflow locally
  4. Re-run the workflow to verify the fix

🦅 Observed from above by Dev Hawk

@pelikhan
Copy link
Contributor

@copilot rewrite actions/setup-activation/index.js as a shell script with no runtime dependencies.

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot rewrite actions/setup-activation/index.js as a shell script with no runtime dependencies.

Converted to shell script in 6a97b67. The action now uses a composite action with a pure Bash script (setup.sh) that has no runtime dependencies.

Changes:

  • Replaced Node.js action with composite action using Bash
  • Uses cat with here-documents to write 11 embedded .cjs files
  • No npm packages or Node.js runtime required
  • Properly handles GitHub Actions outputs via $GITHUB_OUTPUT
  • All 123 workflows compile successfully with the new implementation

@github-actions
Copy link
Contributor

⚠️ Dev Hawk Report - Failure Analysis

Workflow Run: #3170

  • Status: failure
  • Commit: 6a97b67
  • Duration: ~3 seconds (failed immediately)

Root Cause Analysis

The workflow failed during the activation job's "Set up job" phase because the runner label ubuntu-slim does not exist in GitHub Actions.

The Problem

The activation job is configured to use:

jobs:
  activation:
    runs-on: ubuntu-slim  # ❌ This runner label doesn't exist

This comes from the constant defined in pkg/constants/constants.go:

// DefaultActivationJobRunnerImage is the default runner image for activation and pre-activation jobs
// See (redacted)
const DefaultActivationJobRunnerImage = "ubuntu-slim"

Why It Failed

GitHub Actions rejected the workflow immediately because it cannot find any available runners with the ubuntu-slim label. The "Set up job" step failed before any actual workflow steps could execute.

Investigation Details

From the workflow run details:

  • Failed Job: activation
  • Failure Point: "Set up job" (step 1)
  • Started: 2025-12-20T18:57:06Z
  • Failed: 2025-12-20T18:57:08Z (2 seconds)
  • Downstream Jobs: All skipped (agent, detection, safe_outputs, conclusion)

The compiled workflow file .github/workflows/dev.lock.yml contains 3 occurrences of ubuntu-slim:

  • Line 41: activation job
  • Line 6956: safe_outputs job
  • Line 7719: conclusion job

Recommended Actions

Immediate Fix:

  • Change DefaultActivationJobRunnerImage in pkg/constants/constants.go from "ubuntu-slim" to "ubuntu-latest"
  • Run make recompile to regenerate all .lock.yml files with the correct runner
  • Test the Dev workflow again

Alternative Fix (if ubuntu-slim is intentionally being used):

  • Verify the correct runner label for the 1-vCPU Linux runner
  • Check if this feature is available in public preview or requires enablement
  • Update the constant with the correct label once confirmed

Code Change:

-const DefaultActivationJobRunnerImage = "ubuntu-slim"
+const DefaultActivationJobRunnerImage = "ubuntu-latest"

Then rebuild and recompile:

make build
make recompile

Category

Infrastructure/Configuration Error - Invalid runner label in constants


💡 Dev Hawk Insight: The referenced GitHub blog post suggests a 1-vCPU runner was planned, but the ubuntu-slim label may not be the correct identifier or may not be available yet in this repository.

🦅 Observed from above by Dev Hawk

@pelikhan
Copy link
Contributor

@copilot merge main

Copilot AI and others added 3 commits December 21, 2025 18:56
…-action-setup-activation

# Conflicts:
#	.github/workflows/ai-moderator.lock.yml
#	.github/workflows/campaign-generator.lock.yml
#	.github/workflows/go-file-size-reduction.campaign.g.lock.yml
#	.github/workflows/workflow-generator.lock.yml
Copy link
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot merge main

Merged main in b27fa0d. Resolved merge conflicts in 3 lock files, removed deleted workflow, and recompiled all 120 workflows successfully (120/120).

@pelikhan pelikhan marked this pull request as draft December 21, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants