Last active
April 26, 2024 19:52
-
-
Save Link-/f817f7523a3ac5de6861efd7be6bc3fb to your computer and use it in GitHub Desktop.
Write your first workflow with GitHub Actions and GitHub APIs - beginner friendly tutorial!
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
name: Create a comment on new issues | |
on: | |
issues: | |
types: [opened] | |
permissions: write-all | |
jobs: | |
comment-with-action: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "dump github context" | |
run: echo '${{ toJSON(github.event) }}' | jq | |
shell: bash | |
- name: Create comment | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
This is a multi-line test comment | |
- With GitHub **Markdown** :sparkles: | |
- Created by [create-or-update-comment][1] | |
[1]: https://github.com/peter-evans/create-or-update-comment | |
reactions: '+1' | |
comment-with-api: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create comment with API | |
run: | | |
gh api -X POST \ | |
https://api.github.com/repos/${ORGANIZATION}/${REPOSITORY}/issues/${ISSUE_NUMBER}/comments \ | |
-f body=' | |
Comment but from the API call not action | |
' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ORGANIZATION: ${{ github.event.organization.login }} | |
REPOSITORY: ${{ github.event.repository.name }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} |
Nice @Link- thank you for adding it. I was coming from working with Gitlab CICD and your course was a great resource. Also the official docs so thank you
I am currently facing this issue and I will appreciate any help I can get
Run gh api -X POST
gh api -X POST
https://api.github.com/repo/${ORGANIZATION}/${REPOSITORY}/issues/${ISSUE_NUMBER/comments}
-f body=" Comment from Github API Bot"
shell: /usr/bin/bash -e {0}
env:
GITHUB_TOKEN: ***
ORGANIZATION: Gerald-Izuchukwu
REPOSITORY: Meal-Microservice-App
ISSUE_NUMBER: 10
gh: Not Found (HTTP 404)
{"message":"Not Found","documentation_url":"https://docs.github.com/rest"}
Error: Process completed with exit code 1.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added the
permissions: write-all
- this was created before GITHUB_TOKEN permissions were introduced :)