Skip to content

autocheckcombos trigger only on originalMappings.csv edit and add bad… #19

autocheckcombos trigger only on originalMappings.csv edit and add bad…

autocheckcombos trigger only on originalMappings.csv edit and add bad… #19

name: Find Shorter Candidates
on:
push:
branches:
- main
paths:
- 'data/originalMappings.csv' # This will trigger for any file change in the data directory
pull_request:
branches:
- main
paths:
- 'data/originalMappings.csv' # This will trigger for any file change in the data directory
schedule:
- cron: '0 0 1 * *' #once a month
jobs:
find-shorter-candidates:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9' # Specify your required Python version
- name: Install dependencies
id: dependencies
run: |
sudo apt-get install -y expect
- name: Run find-num.py
id: find_num
run: |
unbuffer python find-num.py --range 255 | tee result.txt
- name: Update originalMappings.csv
id: update_mappings
run: |
NEW_CANDIDATES_FOUND=false
while IFS= read -r line; do
if [[ "$line" =~ ^[0-9] ]]; then
NEW_CANDIDATES_FOUND=true
ASCII_NUM=$(echo $line | cut -d',' -f1)
NEW_PYTHON_CODE=$(echo $line | cut -d',' -f2)
sed -i "s/^$ASCII_NUM,.*/$ASCII_NUM,$NEW_PYTHON_CODE/" data/originalMappings.csv
fi
done < result.txt
if [ "$NEW_CANDIDATES_FOUND" = true ]; then
echo "new_candidates=true" >> $GITHUB_OUTPUT
else
echo "new_candidates=false" >> $GITHUB_OUTPUT
fi
- name: Remove result.txt if new candidates found
if: steps.update_mappings.outputs.new_candidates == 'true'
run: rm result.txt
- name: Create or Update Pull Request
if: steps.update_mappings.outputs.new_candidates == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Update originalMappings.csv with shorter candidates"
body: "This PR updates data/originalMappings.csv with new shorter candidates found by find-num.py."
base: main
branch: update-original-mappings
commit-message: "Update originalMappings.csv with shorter candidates"
delete-branch: false
- name: Upload Existing Combinations Log
if: steps.update_mappings.outputs.new_candidates == 'false'
uses: actions/upload-artifact@v3
with:
name: results-log
path: result.txt