Skip to content
Merged
Changes from 1 commit
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
54 changes: 53 additions & 1 deletion .github/workflows/nx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,27 @@ jobs:
- run: yarn install --immutable
- uses: nrwl/nx-set-shas@v4

# --- PRs ---
# --- Create pending status at start for PRs ---
- name: Create Nx Cloud Status (pending)
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const nxCloudUrl = `https://cloud.nx.app/orgs/606dcb5cdc2a2b00059cc0e9/workspaces/6929fbef73e98d8094d2a343/overview?branch=${prNumber}`;

await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.pull_request.head.sha,
state: 'pending',
avatar_url: 'https://avatars.githubusercontent.com/in/80458',
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The avatar_url parameter is not a valid parameter for the createCommitStatus API. According to the GitHub API documentation, the valid parameters are: state, target_url, description, and context. The avatar_url parameter will be ignored.

If you want to associate an avatar with the status, consider using a GitHub App instead of the commit status API, or remove this parameter as it has no effect.

Suggested change
avatar_url: 'https://avatars.githubusercontent.com/in/80458',

Copilot uses AI. Check for mistakes.
target_url: nxCloudUrl,
description: 'View Nx Cloud dashboard for this PR',
context: 'Nx Cloud'
});
Comment on lines 67 to 77
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The workflow needs statuses: write permission to create commit statuses via the GitHub API. Currently, the permissions only include actions: read and contents: read, which will cause the createCommitStatus API calls to fail with a 403 error.

Add statuses: write to the permissions section:

permissions:
  actions: read
  contents: read
  statuses: write

Copilot uses AI. Check for mistakes.

# --- PRs ---
- if: github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'ci:normal')
run: yarn nx run-many -t $ALL_TASKS -c production -p="tag:ci:normal"
Expand All @@ -53,3 +73,35 @@ jobs:
- if: github.event_name == 'push' &&
github.ref == 'refs/heads/next'
run: yarn nx run-many -t $ALL_TASKS -c production -p="tag:ci:normal,tag:ci:merged"

# --- Final status update (success / failure / error) ---
- name: Finalize Nx Cloud Status
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const nxCloudUrl = `https://cloud.nx.app/orgs/606dcb5cdc2a2b00059cc0e9/workspaces/6929fbef73e98d8094d2a343/overview?branch=${prNumber}`;

const jobStatus = '${{ job.status }}'; // 'success', 'failure', 'cancelled', 'skipped'
/** Map job.status -> GitHub Statuses API state */
const stateMap = {
success: 'success',
failure: 'failure',
cancelled: 'error',
skipped: 'error'
};
const state = stateMap[jobStatus] ?? 'error';

await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.pull_request.head.sha,
state,
avatar_url: 'https://avatars.githubusercontent.com/in/80458',
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The avatar_url parameter is not a valid parameter for the createCommitStatus API. According to the GitHub API documentation, the valid parameters are: state, target_url, description, and context. The avatar_url parameter will be ignored.

If you want to associate an avatar with the status, consider using a GitHub App instead of the commit status API, or remove this parameter as it has no effect.

Suggested change
avatar_url: 'https://avatars.githubusercontent.com/in/80458',

Copilot uses AI. Check for mistakes.
target_url: nxCloudUrl,
description: state === 'success'
? 'Nx Cloud run finished successfully'
: `Nx Cloud run ended with status: ${jobStatus}`,
context: 'Nx Cloud'
});
Loading