Skip to content

Commit 5c07d4e

Browse files
authored
chore: CI generated commit hash and no gen comment (#3301)
1 parent 01ef934 commit 5c07d4e

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

.github/workflows/check.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- uses: marocchino/sticky-pull-request-comment@v2
3131
with:
3232
message: |
33-
### 🔨 The generated code will be pushed at the end of the CI.
33+
### 🪓 The generated code will be pushed at the end of the CI.
3434
3535
Action triggered by commit [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}).
3636
@@ -472,13 +472,24 @@ jobs:
472472

473473
- name: update generation comment
474474
uses: marocchino/sticky-pull-request-comment@v2
475+
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT == '' }}
476+
with:
477+
message: |
478+
### No code generated
479+
480+
_If you believe code should've been generated, please, [report the issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=bug%2Ctriage&projects=&template=Bug_report.yml&title=%5Bbug%5D%3A+)._
481+
482+
- name: update generation comment
483+
uses: marocchino/sticky-pull-request-comment@v2
484+
if: ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT != '' }}
475485
with:
476486
message: |
477487
### ✔️ Code generated!
478488
479489
| Name | Link |
480490
|---------------------------------|------------------------|
481-
| 🔨 Triggered by | [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}) |
491+
| 🪓 Triggered by | [`${{ github.sha }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ github.sha }}) |
492+
| 🍃 Generated commit | [`${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}) |
482493
| 🌲 Generated branch | [`generated/${{ github.head_ref }}`](${{ github.event.pull_request.base.repo.html_url }}/tree/generated/${{ github.head_ref }}) |
483494
484495
- name: Spread generation to each repository

scripts/ci/codegen/pushGeneratedCode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable no-console */
2+
import { setOutput } from '@actions/core';
3+
24
import { configureGitHubAuthor, ensureGitHubToken, MAIN_BRANCH, run } from '../../common.js';
35
import { getNbGitDiff } from '../utils.js';
46

@@ -76,6 +78,8 @@ Co-authored-by: %an <%ae>
7678
await run('git add .');
7779
await run(`git commit -m "${message}"`);
7880
await run(`git push origin ${branchToPush}`);
81+
82+
setOutput('GENERATED_COMMIT', await run('git rev-parse HEAD'));
7983
}
8084

8185
if (import.meta.url.endsWith(process.argv[1])) {

scripts/ci/githubActions/createMatrix.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-case-declarations */
2-
import * as core from '@actions/core';
2+
import { setOutput } from '@actions/core';
33

44
import { CLIENTS, createClientName, GENERATORS, LANGUAGES } from '../../common.js';
55
import { getLanguageFolder, getTestExtension, getTestOutputFolder } from '../../config.js';
@@ -139,31 +139,31 @@ async function createClientMatrix(baseBranch: string): Promise<void> {
139139
// If there are updates for the Swift client, we allow ourselves to run the CTS on macOS
140140
const swiftData = clientMatrix.client.find((c) => c.language === 'swift');
141141
if (swiftData) {
142-
core.setOutput('SWIFT_DATA', JSON.stringify(swiftData));
143-
core.setOutput('RUN_MACOS_SWIFT_CTS', true);
142+
setOutput('SWIFT_DATA', JSON.stringify(swiftData));
143+
setOutput('RUN_MACOS_SWIFT_CTS', true);
144144
}
145145

146146
// If there are updates for the Kotlin client, we allow ourselves to run the build step on macOS
147147
const runKotlin = clientMatrix.client.find((c) => c.language === 'kotlin');
148148
if (runKotlin) {
149-
core.setOutput('RUN_MACOS_KOTLIN_BUILD', true);
149+
setOutput('RUN_MACOS_KOTLIN_BUILD', true);
150150
}
151151

152152
const javascriptData = clientMatrix.client.find((c) => c.language === 'javascript');
153153
if (javascriptData) {
154-
core.setOutput('JAVASCRIPT_DATA', JSON.stringify(javascriptData));
155-
core.setOutput('RUN_GEN_JAVASCRIPT', true);
154+
setOutput('JAVASCRIPT_DATA', JSON.stringify(javascriptData));
155+
setOutput('RUN_GEN_JAVASCRIPT', true);
156156
clientMatrix.client = clientMatrix.client.filter((c) => c.language !== 'javascript');
157157
}
158158

159159
const shouldRun = clientMatrix.client.length > 0;
160160

161-
core.setOutput('RUN_GEN', shouldRun);
162-
core.setOutput('GEN_MATRIX', JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX));
161+
setOutput('RUN_GEN', shouldRun);
162+
setOutput('GEN_MATRIX', JSON.stringify(shouldRun ? clientMatrix : EMPTY_MATRIX));
163163
}
164164

165165
function createSpecMatrix(): void {
166-
core.setOutput(
166+
setOutput(
167167
'MATRIX',
168168
JSON.stringify({
169169
bundledPath: 'specs/bundled',

0 commit comments

Comments
 (0)