-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (36 loc) · 1.6 KB
/
log-acknowledgment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Acknowledgment Auto-Close and Log
on:
issue_comment:
types: [created]
jobs:
acknowledge:
runs-on: ubuntu-latest
# First, we add conditions to check if the comment contains "Acknowledged",
# if the comment comes from the assignee, and if the issue is an acknowledgment issue.
if: contains(github.event.comment.body, 'Confirmed') &&
github.event.issue.assignee.login == github.event.comment.user.login &&
contains(github.event.issue.title, 'Acknowledgment request')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get current date and username
id: vars
run: |
echo "DATE=$(date -u)" >> $GITHUB_ENV
echo "USER=${{ github.event.comment.user.login }}" >> $GITHUB_ENV
echo "ISSUE_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
- name: Append acknowledgment to file
run: |
echo "- **${{ env.USER }}**: Acknowledged on ${{ env.DATE }} (Issue #${{ env.ISSUE_NUMBER }})" >> acknowledgments.md
- name: Commit and push changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add acknowledgments.md
git commit -m "Added acknowledgment for ${{ env.USER }} on ${{ env.DATE }}"
git push origin main
- name: Close the issue
env:
GH_TOKEN: ${{ github.token }}
run: |
gh issue close ${{ github.event.issue.number }} --comment "Thank you, ${{ env.USER }}, for confirming that you have read the infosec materials."