|
1 |
| -# This is a basic workflow to help you get started with Actions |
| 1 | +name: Auto Message and Star |
2 | 2 |
|
3 |
| -name: First-Greeting |
4 |
| - |
5 |
| -# Controls when the workflow will run |
6 | 3 | 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] |
14 | 6 |
|
15 |
| -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
16 | 7 | 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: |
20 | 9 | runs-on: ubuntu-latest
|
21 | 10 |
|
22 |
| - # Steps represent a sequence of tasks that will be executed as part of the job |
23 | 11 | 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 |
30 | 14 |
|
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