name: Wordlist Updater - etc files

# Controls when the workflow will run
on:
  schedule:
    - cron: '30 20 1,15 * *' # run at 8:30p on 1st and 15th

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

jobs:
  updatejob:
    if: vars.RUN_UPDATERS == 1
    # 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:
      - uses: actions/checkout@v3

      # Runs a single command using the runners shell
      - name: update wordlist
        run: cd .bin/etc-files-list-update/ && ./update.sh

      - name: Switching from HTTPS to SSH
        run: git remote set-url origin git@github.com:danielmiessler/SecLists.git

      - name: Stage changed files
        run: git add Discovery/Variables/awesome-environment-variable-names.txt

      - name: Configure git email and username
        run: |
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"

      - name: Check git status and save to output
        id: myoutputs
        run: |
          git status
          echo "::set-output name=gitstatus::$(git status --porcelain)"

      - name: Commit changed files
        if: steps.myoutputs.outputs.gitstatus != ''
        run: git commit -m "[Github Action] Updated LFI-etc-files-of-all-linux-packages.txt"

      - name: Push changes # push the output folder to your repo
        if: steps.myoutputs.outputs.gitstatus != ''
        uses: ad-m/github-push-action@4cc74773234f74829a8c21bc4d69dd4be9cfa599 # master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          force: true
