Merge pull request #376 from kebaldwi/kebaldwi #12
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: Record Traffic Insights | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '0 0 */14 * *' # Runs every 14 days at midnight UTC | |
jobs: | |
log-traffic-insights: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' # Specify the Python version you need | |
- name: Install dependencies | |
run: | | |
pip install requests beautifulsoup4 pdfkit | |
sudo apt-get install -y wkhtmltopdf # Install wkhtmltopdf | |
- name: Run traffic insights script | |
env: | |
ACCESS_TOKEN: ${{ secrets.KEY }} # Use GitHub token or set your own secret | |
OWNER: ${{ secrets.USERNAME }} # Replace with your GitHub username | |
REPO: ${{ secrets.REPO }} # Replace with your repository name | |
run: | | |
python CODE/SCRIPTS/traffic_logging.py | |
- name: Commit changes to CSV | |
run: | | |
git config --local user.name "github-actions" | |
git config --local user.email "action@github.com" | |
git fetch origin # Fetch all branches | |
git checkout TRAFFIC || git checkout -b TRAFFIC # Create and switch to TRAFFIC branch if it doesn't exist | |
git add CODE/TRAFFIC/traffic_log.csv | |
git commit -m "Update traffic log with new insights" || echo "No changes to commit" | |
git push origin TRAFFIC # Push changes to the TRAFFIC branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token for authentication | |
- name: Upload CSV Log | |
uses: actions/upload-artifact@v3 | |
with: | |
name: traffic_log.csv | |
path: CODE/TRAFFIC/traffic_log.csv # Adjust path if necessary |