generated from EVerest/everest-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
186 additions
and
0 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 |
---|---|---|
|
@@ -128,3 +128,51 @@ jobs: | |
git config --list --global | ||
test "$(git config --get user.email)" = "[email protected]" | ||
test "$(git config --get user.name)" = "Github Service Account" | ||
test-find-issue-comment: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Find issue comment | ||
# LTODO: switch to main branch | ||
uses: everest/everest-ci/github-actions/find-issue-comment@feature/add-render-jinja2-action | ||
id: find-issue-comment | ||
with: | ||
owner: everest | ||
repo: everest | ||
token: ${{ secrets.SA_GITHUB_PAT }} | ||
issue_number: 98 | ||
user: pionix-compiler | ||
test-update-issue-comment: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Find issue comment | ||
# LTODO: switch to main branch | ||
uses: everest/everest-ci/github-actions/find-issue-comment@feature/add-render-jinja2-action | ||
id: find-issue-comment | ||
with: | ||
owner: everest | ||
repo: everest | ||
token: ${{ secrets.SA_GITHUB_PAT }} | ||
issue_number: 98 | ||
user: pionix-compiler | ||
- name: Update issue comment | ||
# LTODO: switch to main branch | ||
uses: everest/everest-ci/github-actions/update-issue-comment@feature/add-render-jinja2-action | ||
with: | ||
owner: everest | ||
repo: everest | ||
token: ${{ secrets.SA_GITHUB_PAT }} | ||
comment_id: ${{ steps.find-issue-comment.outputs.comment_id }} | ||
body: "Hello World 2" | ||
# test-create-issue-comment: | ||
# runs-on: ubuntu-22.04 | ||
# steps: | ||
# - name: Create issue comment | ||
# # LTODO: switch to main branch | ||
# uses: everest/everest-ci/github-actions/create-issue-comment@feature/add-render-jinja2-action | ||
# id: create-issue-comment | ||
# with: | ||
# owner: everest | ||
# repo: everest | ||
# token: ${{ secrets.SA_GITHUB_PAT }} | ||
# issue_number: 98 | ||
# body: "Hello World" |
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,36 @@ | ||
name: Create issue comment | ||
description: Create issue comment | ||
inputs: | ||
owner: | ||
description: 'Owner' | ||
required: true | ||
type: string | ||
repo: | ||
description: 'Repo' | ||
required: true | ||
type: string | ||
issue_number: | ||
description: 'Issue number' | ||
required: true | ||
type: int | ||
token: | ||
description: 'Token' | ||
required: true | ||
type: string | ||
body: | ||
description: 'Body' | ||
required: true | ||
type: string | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Create comment | ||
shell: bash | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ inputs.token }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ inputs.owner }}/${{ inputs.repo }}/issues/${{ inputs.issue_number }}/comments \ | ||
-d '{"body":"${{ inputs.body }}"}' |
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,66 @@ | ||
name: Find issue comment by user | ||
description: Find issue comment by user | ||
inputs: | ||
owner: | ||
description: 'Owner' | ||
required: true | ||
type: string | ||
repo: | ||
description: 'Repo' | ||
required: true | ||
type: string | ||
issue_number: | ||
description: 'Issue number' | ||
required: true | ||
type: int | ||
token: | ||
description: 'Token' | ||
required: true | ||
type: string | ||
user: | ||
description: 'User' | ||
required: true | ||
type: string | ||
outputs: | ||
comment_id: | ||
description: 'Comment id' | ||
value: ${{ steps.find-comment.outputs.comment_id }} | ||
success: | ||
description: 'Success' | ||
value: ${{ steps.find-comment.outputs.success }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get all comments | ||
shell: bash | ||
run: | | ||
curl -L \ | ||
-o "output.json" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ inputs.token }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ inputs.owner }}/${{ inputs.repo }}/issues/${{ inputs.issue_number }}/comments | ||
id: comments | ||
- name: Find comment | ||
id: find-comment | ||
shell: python3 {0} | ||
run: | | ||
import json, os | ||
comment_id = None | ||
success = "False" | ||
with open('output.json') as f: | ||
comments = json.load(f) | ||
for comment in comments: | ||
if comment['user']['login'] == "${{ inputs.user }}": | ||
if comment_id is not None: | ||
raise Exception(f"Found multiple comments by user ${{ inputs.user }}") | ||
comment_id = comment['id'] | ||
success = "True" | ||
with open(os.environ['GITHUB_OUTPUT'], 'a') as f: | ||
f.write(f'comment_id={ comment_id }\n') | ||
f.write(f'success={ success }\n') | ||
- name: Result | ||
shell: bash | ||
run: | | ||
echo "comment_id: ${{ steps.find-comment.outputs.comment_id }}" | ||
echo "success: ${{ steps.find-comment.outputs.success }}" |
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,36 @@ | ||
name: Update issue comment | ||
description: Update issue comment | ||
inputs: | ||
owner: | ||
description: 'Owner' | ||
required: true | ||
type: string | ||
repo: | ||
description: 'Repo' | ||
required: true | ||
type: string | ||
token: | ||
description: 'Token' | ||
required: true | ||
type: string | ||
comment_id: | ||
description: 'Comment id' | ||
required: true | ||
type: int | ||
body: | ||
description: 'Body' | ||
required: true | ||
type: string | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Update issue | ||
shell: bash | ||
run: | | ||
curl -L \ | ||
-X PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ inputs.token }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ inputs.owner }}/${{ inputs.repo }}/issues/comments/${{ inputs.comment_id }} \ | ||
-d '{"body":"${{ inputs.body }}"}' |