Repository navigation
Update FAANG data #38
This file contains hidden or 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: Update FAANG data | |
| # creating schedule for the script to run | |
| # reference: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax | |
| on: | |
| schedule: | |
| # - cron: sets the time ("0 8" = 8am) and frequency ("* * 6" = every 6 days) | |
| # cron format is as follows: minute hour day-of-month month day-of-week | |
| # reference: https://cicube.io/blog/github-actions-cron/#how-to-use-cron-syntax-in-github-actions | |
| - cron: '0 8 * * 6' # Runs Saturday morning | |
| # the next line allows manual triggering of the workflow from the Actions tab in GitHub | |
| workflow_dispatch: | |
| # setting permissions for the job to be able to push changes to the repository | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-faang-data: | |
| # this is the type of virtual machine to run the job on | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| # here I need to ensure all the necessary packages (libraries used in my script) are installed on the virtual environment first | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install yfinance pandas matplotlib | |
| - name: Run faang.py | |
| run: | | |
| python faang.py | |
| # committing changes to the repository | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name 'github-actions' | |
| git config --global user.email 'github-actions@github.com' | |
| git add -A | |
| git diff --quiet --cached || git commit -m "Automated update of FAANG data" | |
| - name: Push changes | |
| run: | | |
| git push origin HEAD |