Bump mysql-connector-python from 9.0.0 to 9.1.0 in /.scripts #3
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: Pull Data | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
# schedule: | |
# - cron: "0 */6 * * *" # Runs every 6 hours | |
permissions: | |
contents: write | |
jobs: | |
update-db: | |
runs-on: ubuntu-latest | |
env: | |
DB_HOST: ${{ secrets.DB_HOST }} | |
DB_USER: ${{ secrets.DB_USER }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
DB_PORT: ${{ secrets.DB_PORT }} | |
DB_NAME: ${{ secrets.DB_NAME }} | |
steps: | |
- name: Get GitHub action IP | |
id: ip | |
uses: haythem/[email protected] | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Setting environment variables | |
run: | | |
echo "AWS_DEFAULT_REGION=us-east-1" >> $GITHUB_ENV | |
- name: Add GitHub Actions IP to Security group | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 3306 --cidr ${{ steps.ip.outputs.ipv4 }}/32 > /dev/null | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }} | |
- name: Install requirmenets | |
run: | | |
pip install -r ./.scripts/requirements.txt | |
- uses: actions/checkout@v4 | |
name: Pull data from database and push to repository | |
- run: | | |
python3 .scripts/pull_data.py | |
echo "Updated at $(date)" >> updated_at.txt | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Updated at $(date)" | |
git push | |
- name: Remove GitHub Actions IP from security group | |
if: always() | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 3306 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }} |