3838 - run : yarn install --immutable
3939 - uses : nrwl/nx-set-shas@v4
4040
41- # --- PRs ---
41+ # --- Create pending status at start for PRs ---
42+ - name : Create Nx Cloud Status (pending)
43+ if : github.event_name == 'pull_request'
44+ uses : actions/github-script@v7
45+ with :
46+ script : |
47+ const prNumber = context.payload.pull_request.number;
48+ const nxCloudUrl = `https://cloud.nx.app/orgs/606dcb5cdc2a2b00059cc0e9/workspaces/6929fbef73e98d8094d2a343/overview?branch=${prNumber}`;
49+
50+ await github.rest.repos.createCommitStatus({
51+ owner: context.repo.owner,
52+ repo: context.repo.repo,
53+ sha: context.payload.pull_request.head.sha,
54+ state: 'pending',
55+ avatar_url: 'https://avatars.githubusercontent.com/in/80458',
56+ target_url: nxCloudUrl,
57+ description: 'View Nx Cloud dashboard for this PR',
58+ context: 'Nx Cloud'
59+ });
60+
61+ # --- PRs ---
4262 - if : github.event_name == 'pull_request' &&
4363 contains(github.event.pull_request.labels.*.name, 'ci:normal')
4464 run : yarn nx run-many -t $ALL_TASKS -c production -p="tag:ci:normal"
5373 - if : github.event_name == 'push' &&
5474 github.ref == 'refs/heads/next'
5575 run : yarn nx run-many -t $ALL_TASKS -c production -p="tag:ci:normal,tag:ci:merged"
76+
77+ # --- Final status update (success / failure / error) ---
78+ - name : Finalize Nx Cloud Status
79+ if : github.event_name == 'pull_request' && always()
80+ uses : actions/github-script@v7
81+ with :
82+ script : |
83+ const prNumber = context.payload.pull_request.number;
84+ const nxCloudUrl = `https://cloud.nx.app/orgs/606dcb5cdc2a2b00059cc0e9/workspaces/6929fbef73e98d8094d2a343/overview?branch=${prNumber}`;
85+
86+ const jobStatus = '${{ job.status }}'; // 'success', 'failure', 'cancelled', 'skipped'
87+ /** Map job.status -> GitHub Statuses API state */
88+ const stateMap = {
89+ success: 'success',
90+ failure: 'failure',
91+ cancelled: 'error',
92+ skipped: 'error'
93+ };
94+ const state = stateMap[jobStatus] ?? 'error';
95+
96+ await github.rest.repos.createCommitStatus({
97+ owner: context.repo.owner,
98+ repo: context.repo.repo,
99+ sha: context.payload.pull_request.head.sha,
100+ state,
101+ avatar_url: 'https://avatars.githubusercontent.com/in/80458',
102+ target_url: nxCloudUrl,
103+ description: state === 'success'
104+ ? 'Nx Cloud run finished successfully'
105+ : `Nx Cloud run ended with status: ${jobStatus}`,
106+ context: 'Nx Cloud'
107+ });
0 commit comments