Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/generate-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: TODO

on:
pull_request:
paths:
- "**/*.po"

permissions:
contents: read

jobs:
generate-pr-comment:
name: TODO
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
persist-credentials: false
- name: TODO
uses: actions/setup-python@v7
with:
python-version: "3.13"
cache: "pip"
- name: Instalar dependencias
run: python -m pip install -r requirements-own.txt
- name: TODO
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
mkdir -p out
git diff -z --name-only --diff-filter=ACMR HEAD^1 HEAD -- '*.po' > out/changed.txt
if [[ ! -s out/changed.txt ]]; then
exit 0
fi
echo "$PR_NUMBER" > out/pr-number
xargs -0 python scripts/list_missing_entries.py --github < out/changed.txt > out/comment.md
- uses: actions/upload-artifact@v5
with:
name: missing-entries
path: |
out/pr-number
out/comment.md
if-no-files-found: ignore
retention-days: 1
91 changes: 39 additions & 52 deletions .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,55 @@
name: Agrega comentario a PR

on:
pull_request_target:
workflow_run:
workflows: ["TODO"]
types: [completed]

permissions:
contents: read
permissions: {}

jobs:
define-comment:
name: Entradas sin traducción
write-comment:
runs-on: ubuntu-22.04
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
comment: ${{ steps.create-pr-comment.outputs.comment }}
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
permissions:
actions: read
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Preparar Python v3.13
uses: actions/setup-python@v7
with:
python-version: "3.13"
cache: "pip"
# checkout these files from the base branch to guarantee they haven't been
# modified by the PR
- uses: actions/checkout@v6
with:
path: base-branch
sparse-checkout-cone-mode: false
sparse-checkout: |
requirements-own.txt
scripts/list_missing_entries.py
- name: Instalar dependencias
run: |
python -m pip install -r base-branch/requirements-own.txt
- name: Obtiene lista de archivos con cambios
id: changed-files
uses: tj-actions/changed-files@v47
- uses: actions/download-artifact@v5
continue-on-error: true
with:
files: |
**/*.po
- name: Calcular entradas faltantes
if: steps.changed-files.outputs.any_changed == 'true'
id: create-pr-comment
name: missing-entries
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: TODO
id: pr
env:
CHANGED_PO_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
GH_TOKEN: ${{ github.token }}
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
{
echo 'comment<<EOF'
python base-branch/scripts/list_missing_entries.py --github $CHANGED_PO_FILES
echo EOF
} >> "$GITHUB_OUTPUT"
if [[ ! -f pr-number ]]; then
echo 'TODO'
exit 0
fi
pr="$(head -n1 pr-number)"
if [[ ! "$pr" =~ ^[0-9]+$ ]]; then
echo 'TODO'
exit 1
fi
actual_sha="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$pr" --jq .head.sha)"
if [[ "actual_sha" != "$HEAD_SHA" ]]; then
echo 'TODO'
exit 0
fi
echo "pr=$pr" >> "$GITHUB_OUTPUT"

write-comment:
runs-on: ubuntu-22.04
needs: [define-comment]
if: needs.define-comment.outputs.any_changed == 'true'
permissions:
issues: write
pull-requests: write
steps:
- name: Agregar comentario con entradas faltantes
if: steps.pr.outputs.pr != ''
uses: thollander/actions-comment-pull-request@v3
with:
message: ${{ needs.define-comment.outputs.comment }}
file-path: comment.md
pr-number: ${{ steps.pr.outputs.pr }}
comment-tag: missing-entries
Loading