# This is a basic workflow to help you get started with Actions
name: twitter collections

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  schedule:
    - cron: '0 18 * * 6'
  push:
    paths:
    - 'twscraper.py'
    - '.github/workflows/twitter.yml'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: '3.9.0' # Version range or exact version of a Python version to use, using SemVer's version range syntax
      - uses: py-actions/py-dependency-install@v2   
        with:
          path: requirements.txt
      - shell: bash
        env: # Or as an environment variable
          CONSUMER_KEY: ${{ secrets.CONSUMER_KEY }}
          CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }}
          ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
          ACCESS_SECRET: ${{ secrets.ACCESS_SECRET }}
        run: python twscraper.py
      - name: Deploy Changes
        run: |
          git remote add gh-token "https://github.com/decentralized-id/decentralized-id.github.io.git"
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git pull
          git commit -a -m "add twitter collection"
          git push gh-token master