<commit_before>name: 'Lingui message extraction'

on:
  push:
    paths:
      - 'src/**'
      - '.github/**'

env:
  CI: true

jobs:
  extract:
    name: 'Extract messages'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          # Needed by ad-m/github-push-action:
          persist-credentials: false
          fetch-depth: 0
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v2
        with:
          path: node_modules
          # path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-node_modules2-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-node_modules2-
      - run: yarn --frozen-lockfile --production=false
      - name: Extract messages
        # We need to run extraction twice as Lingui has a bug where the second pass removes the default for messages with the same id as the default
        run: |
          yarn extract
          yarn extract
      - name: Has changes
        id: has-changes
        run: echo "::set-output name=changed::$(if [[ `git status --porcelain` ]]; then echo "true"; else echo "false"; fi)"
      - name: Commit changes
        if: steps.has-changes.outputs.changed == 'true'
        run: |
          git config --local user.email "<EMAIL>"
          git config --local user.name "GitHub Action"
          git commit -m "Update i18n messages" -a
      - name: Push changes
        if: steps.has-changes.outputs.changed == 'true'
        uses: ad-m/github-push-action@v0.6.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}<commit_msg>Update extracted messages through a PR<commit_after>name: 'Lingui message extraction'

on:
  push:
    paths:
      - 'src/**'
      - '.github/**'

env:
  CI: true

jobs:
  extract:
    name: 'Extract messages'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v2
        with:
          path: node_modules
          # path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-node_modules2-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-node_modules2-
      - run: yarn --frozen-lockfile --production=false
      - name: Extract messages
        # We need to run extraction twice as Lingui has a bug where the second pass removes the default for messages with the same id as the default
        run: |
          yarn extract
          yarn extract
      - name: Has changes
        id: has-changes
        run: echo "::set-output name=changed::$(if [[ `git status --porcelain` ]]; then echo "true"; else echo "false"; fi)"
      - name: Commit changes
        if: steps.has-changes.outputs.changed == 'true'
        run: |
          git config --local user.email "<EMAIL>"
          git config --local user.name "GitHub Action"
          git commit -m "Update i18n messages" -a
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          commit-message: Extract new i18n messages
          title: Extract new i18n messages
          body: New i18n messages need to be added to the messages files so translators can translate them.
          branch: update-messages
{'fraction_non_alphanumeric': 0.11966729272873625, 'fraction_numerical': 0.008049369466058493, 'mean_word_length': 1.9447077409162716, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3729169', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1104, 'n_words': 341}