create-or-update-comment/.github/workflows/test-command.yml

93 lines
2.8 KiB
YAML
Raw Normal View History

2020-04-17 14:05:53 +08:00
name: Test Command
on:
repository_dispatch:
types: [test-command]
jobs:
testCreateOrUpdateComment:
runs-on: ubuntu-latest
steps:
# Get the target repository and branch
- name: Get the target repository and branch
id: vars
run: |
repository=${{ github.event.client_payload.slash_command.repository }}
if [[ -z "$repository" ]]; then repository=${{ github.repository }}; fi
2022-10-18 15:56:13 +08:00
echo "repository=$repository" >> $GITHUB_OUTPUT
2020-04-17 14:05:53 +08:00
branch=${{ github.event.client_payload.slash_command.branch }}
2021-05-12 16:18:15 +08:00
if [[ -z "$branch" ]]; then branch="main"; fi
2022-10-18 15:56:13 +08:00
echo "branch=$branch" >> $GITHUB_OUTPUT
2020-04-17 14:05:53 +08:00
# Checkout the branch to test
- uses: actions/checkout@v3
2020-04-17 14:05:53 +08:00
with:
repository: ${{ steps.vars.outputs.repository }}
ref: ${{ steps.vars.outputs.branch }}
# Test create
- name: Create comment
uses: ./
id: couc
with:
issue-number: 1
body: |
This is a multi-line test comment
2020-06-08 07:38:27 +08:00
- With GitHub **Markdown** :sparkles:
2020-04-17 14:05:53 +08:00
- Created by [create-or-update-comment][1]
[1]: https://github.com/peter-evans/create-or-update-comment
2020-04-17 15:47:21 +08:00
reactions: '+1'
2020-04-17 14:05:53 +08:00
# Test update
- name: Update comment
uses: ./
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
body: |
**Edit:** Some additional info
2020-04-17 15:47:21 +08:00
reactions: eyes
2020-04-17 14:05:53 +08:00
2020-04-17 15:47:21 +08:00
# Test add reactions
- name: Add reactions
2020-04-17 14:05:53 +08:00
uses: ./
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
2020-04-17 15:23:26 +08:00
reactions: heart, hooray, laugh
2020-04-17 14:05:53 +08:00
- name: Add reaction
uses: peter-evans/create-or-update-comment@v2
2020-04-17 14:05:53 +08:00
with:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
2020-04-17 15:47:21 +08:00
reactions: hooray
2021-04-09 13:31:37 +08:00
2022-10-21 11:34:03 +08:00
# Test create with body from file
- id: get-comment-body
run: |
body="$(cat .github/multiline-content.md)"
delimiter="$(openssl rand -hex 8)"
echo "body<<$delimiter" >> $GITHUB_OUTPUT
echo $body >> $GITHUB_OUTPUT
echo $delimiter >> $GITHUB_OUTPUT
- name: Create comment
uses: ./
with:
issue-number: 1
body: ${{ steps.get-comment-body.outputs.body }}
# Test create from template
2021-04-09 13:31:37 +08:00
- name: Render template
id: template
uses: chuhlomin/render-template@v1.5
2021-04-09 13:31:37 +08:00
with:
template: .github/comment-template.md
vars: |
foo: this
bar: that
- name: Create comment
uses: ./
with:
issue-number: 1
body: ${{ steps.template.outputs.result }}