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

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: write
  pages: write
  id-token: write

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# 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:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: "3.11"
          cache: 'pip'
          
      - name: "Install dependencies"
        run: |
          python -VV
          python -m pip install -r requirements.txt
        
      - name: "Run generator"
        run: |
          python .github/workflows/generator.py
          python .github/workflows/friends.py
        env:
          TWITTER_BEARER: ${{ secrets.TWITTER_BEARER }}
        
      - uses: EndBug/add-and-commit@v7
        with:
          default_author: github_actions
          message: '[U] Generate json'

      - name: Setup Pages
        uses: actions/configure-pages@v2

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          # Upload entire repository
          path: '.'

      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
