Update allowlist-request.yml #1
Workflow file for this run
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 Domain to Allowlist and Compile | ||
on: | ||
push: | ||
schedule: | ||
- cron: '0 2 * * *' # Runs every day at 2:00 AM | ||
jobs: | ||
add_domain_and_compile_allowlist: | ||
name: Add Domain to Allowlist and Compile | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@main | ||
- name: Check if issue has label 'allowlist-request' | ||
id: check_label | ||
run: | | ||
if [[ $(jq -r '.issue.labels[].name' $GITHUB_EVENT_PATH) == *"allowlist-request"* ]]; then | ||
echo "Label 'allowlist-request' found." | ||
exit 0 | ||
else | ||
echo "Label 'allowlist-request' not found. Exiting..." | ||
exit 1 | ||
fi | ||
- name: Debug issue comment | ||
if: steps.check_label.outputs.code == '0' | ||
run: echo "Issue Comment Body: ${{ github.event.comment.body }}" | ||
- name: Extract domain from issue comment | ||
id: extract_domain | ||
if: steps.check_label.outputs.code == '0' | ||
run: | | ||
# Extract domain from the issue comment | ||
# Assuming the comment has a textarea input field with id 'domains' | ||
domain=$(echo "${{ github.event.comment.body }}" | grep -oP '(?<=id: domains\n)[^\n]+') | ||
echo "::set-output name=domain::$domain" | ||
- name: Debug extracted domain | ||
if: steps.check_label.outputs.code == '0' | ||
run: echo "Extracted Domain: ${{ steps.extract_domain.outputs.domain }}" | ||
- name: Append domain to allowlist | ||
if: steps.check_label.outputs.code == '0' | ||
run: echo "${{ steps.extract_domain.outputs.domain }}" >> allowlist-request.txt | ||
- name: Start commit change | ||
if: steps.check_label.outputs.code == '0' | ||
run: echo "MSG=Update allowlist with domain at $(date +'%Y%m%d')" >> $GITHUB_ENV | ||
- name: Commit changes | ||
if: steps.check_label.outputs.code == '0' | ||
run: | | ||
git config --global user.email "actions@github.com" | ||
git config --global user.name "GitHub Actions" | ||
git add . | ||
git commit -m "${{ env.MSG }}" | ||
- name: Push changes to dev branch | ||
if: steps.check_label.outputs.code == '0' | ||
run: | | ||
git push origin HEAD:dev |