Skip to content

Commit cd99d27

Browse files
authored
Update first-greeting.yml
1 parent 2f52f40 commit cd99d27

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed
Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Auto Message and Star
22

3-
name: First-Greeting
4-
5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the "main" branch
8-
watch:
9-
branches: [ "main" ]
10-
fork:
11-
branches: [ "main" ]
12-
# Allows you to run this workflow manually from the Actions tab
13-
workflow_dispatch:
4+
issues:
5+
types: [opened]
146

15-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
167
jobs:
17-
# This workflow contains a single job called "build"
18-
build:
19-
# The type of runner that the job will run on
8+
send-message:
209
runs-on: ubuntu-latest
2110

22-
# Steps represent a sequence of tasks that will be executed as part of the job
2311
steps:
24-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
25-
- uses: actions/checkout@v4
26-
27-
# Runs a single command using the runners shell
28-
- name: Run a one-line script
29-
run: echo Hi ${{ github.actor }}!
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
3014

31-
# Runs a set of commands using the runners shell
32-
- name: Add HTML to greetings
33-
run: |
34-
echo '<h1> Give us a star if you haven't yet </h1>' >> $GITHUB_STEP_SUMMARY
35-
echo '<a class="github-button" href="https://github.com/allanoguis/coding-notes" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star your-username/your-repo on GitHub">Star</a>' >> $GITHUB_STEP_SUMMARY
36-
echo '<script async defer src="https://buttons.github.io/buttons.js"></script>' >> $GITHUB_STEP_SUMMARY
15+
- name: Send welcome message
16+
run: |
17+
ISSUE_NUMBER=$(jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
18+
COMMENT_BODY=$(cat <<EOF
19+
Hi @${{ github.actor }}! Thanks for opening this issue. If you haven't already, please consider starring our repository to support us!
20+
<h1>Give us a star if you haven't yet</h1>
21+
<a class="github-button" href="https://github.com/allanoguis/coding-notes" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star allanoguis/coding-notes on GitHub">Star</a>
22+
<script async defer src="https://buttons.github.io/buttons.js"></script>
23+
EOF
24+
)
25+
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" \
26+
-d "{\"body\": \"$COMMENT_BODY\"}" \
27+
"https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments"

0 commit comments

Comments
 (0)