-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (57 loc) · 2.23 KB
/
add-email.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Add email domain from issue
on:
issues:
types: [labeled]
jobs:
add-email-domain:
runs-on: ubuntu-latest
if: ${{ contains(github.event.issue.labels.*.name, 'add-email') }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_PAT }}
- name: Set up Git configuration
run: |
git config user.name "ferrucc-io"
git config user.email "[email protected]"
- name: Extract domain from issue
id: extract_domain
run: |
echo "Issue title:"
echo "${{ github.event.issue.title }}"
# Extract domain name from issue body
DOMAIN_NAME=$(echo "${{ github.event.issue.title }}" | grep -oE '([A-Za-z0-9.-]+\.[A-Za-z]{2,})' | head -n 1)
echo "Domain name extracted: $DOMAIN_NAME"
echo "domain=$DOMAIN_NAME" >> $GITHUB_OUTPUT
- name: Validate domain
run: |
DOMAIN_NAME="${{ steps.extract_domain.outputs.domain }}"
if [ -z "$DOMAIN_NAME" ]; then
echo "No domain name found in issue body."
exit 1
fi
# Attempt to resolve the domain
if ! nslookup "$DOMAIN_NAME"; then
echo "Domain $DOMAIN_NAME does not resolve."
exit 1
fi
- name: Add domain to domains.txt
run: |
DOMAIN_NAME="${{ steps.extract_domain.outputs.domain }}"
echo "$DOMAIN_NAME" >> data/domains.txt
chmod +x scripts/sort_and_clean
./scripts/sort_and_clean
- name: Commit changes
run: |
DOMAIN_NAME="${{ steps.extract_domain.outputs.domain }}"
git add data/domains.txt
git commit -m "Add ${DOMAIN_NAME}" || echo "No changes to commit"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GH_PAT }}
commit-message: "Add ${{ steps.extract_domain.outputs.domain }}"
branch: "add-${{ steps.extract_domain.outputs.domain }}"
title: "Add ${{ steps.extract_domain.outputs.domain }}"
body: "This PR adds ${{ steps.extract_domain.outputs.domain }} to data/domains.txt. Fixes #${{ github.event.issue.number }}"