-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58983 from m-kuhn/commentify
Isolate "post sticky comment" logic
- Loading branch information
Showing
3 changed files
with
161 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Post Sticky Comment | ||
description: Post a sticky comment | ||
inputs: | ||
marker: | ||
description: Unique marker | ||
required: true | ||
type: string | ||
body: | ||
description: Body | ||
required: true | ||
type: string | ||
pr: | ||
description: Pull Request Number | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Create metadata | ||
uses: actions/github-script@v7 | ||
env: | ||
BODY: ${{ inputs.body }} | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
try { | ||
// Get inputs from the GitHub Action | ||
const marker = "${{ inputs.marker }}"; | ||
const body = process.env.BODY; // Transfer input via env variable as it's not possible to access it directly https://github.com/actions/github-script/issues/56#issuecomment-642188313 | ||
const pr = ${{ inputs.pr }}; | ||
// Create the content of the JSON file | ||
const content = JSON.stringify({ | ||
marker: marker, | ||
body: body, | ||
pr_number: pr | ||
}, null, 2); | ||
console.debug(content) | ||
fs.writeFileSync('comment-${{ github.job }}.json', content); | ||
console.log('comment.json file has been written successfully.'); | ||
} catch (error) { | ||
core.setFailed(`Action failed with error: ${error}`); | ||
} | ||
- name: 📤 Upload data | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: comment_artifacts-${{ github.job }} | ||
path: | | ||
comment-${{ github.job }}.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters