Add xcmexico.com #27
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: 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 }}" |