|
1 | 1 | name: Agrega comentario a PR |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request_target: |
| 4 | + workflow_run: |
| 5 | + workflows: ["TODO"] |
| 6 | + types: [completed] |
5 | 7 |
|
6 | | -permissions: |
7 | | - contents: read |
| 8 | +permissions: {} |
8 | 9 |
|
9 | 10 | jobs: |
10 | | - define-comment: |
11 | | - name: Entradas sin traducción |
| 11 | + write-comment: |
12 | 12 | runs-on: ubuntu-22.04 |
13 | | - outputs: |
14 | | - any_changed: ${{ steps.changed-files.outputs.any_changed }} |
15 | | - comment: ${{ steps.create-pr-comment.outputs.comment }} |
| 13 | + if: >- |
| 14 | + github.event.workflow_run.event == 'pull_request' && |
| 15 | + github.event.workflow_run.conclusion == 'success' |
| 16 | + permissions: |
| 17 | + actions: read |
| 18 | + pull-requests: write |
16 | 19 | steps: |
17 | | - - uses: actions/checkout@v6 |
18 | | - with: |
19 | | - ref: ${{ github.event.pull_request.head.sha }} |
20 | | - persist-credentials: false |
21 | | - - name: Preparar Python v3.13 |
22 | | - uses: actions/setup-python@v7 |
23 | | - with: |
24 | | - python-version: "3.13" |
25 | | - cache: "pip" |
26 | | - # checkout these files from the base branch to guarantee they haven't been |
27 | | - # modified by the PR |
28 | | - - uses: actions/checkout@v6 |
29 | | - with: |
30 | | - path: base-branch |
31 | | - sparse-checkout-cone-mode: false |
32 | | - sparse-checkout: | |
33 | | - requirements-own.txt |
34 | | - scripts/list_missing_entries.py |
35 | | - - name: Instalar dependencias |
36 | | - run: | |
37 | | - python -m pip install -r base-branch/requirements-own.txt |
38 | | - - name: Obtiene lista de archivos con cambios |
39 | | - id: changed-files |
40 | | - uses: tj-actions/changed-files@v47 |
| 20 | + - uses: actions/download-artifact@v5 |
| 21 | + continue-on-error: true |
41 | 22 | with: |
42 | | - files: | |
43 | | - **/*.po |
44 | | - - name: Calcular entradas faltantes |
45 | | - if: steps.changed-files.outputs.any_changed == 'true' |
46 | | - id: create-pr-comment |
| 23 | + name: missing-entries |
| 24 | + run-id: ${{ github.event.workflow_run.id }} |
| 25 | + github-token: ${{ github.token }} |
| 26 | + |
| 27 | + - name: TODO |
| 28 | + id: pr |
47 | 29 | env: |
48 | | - CHANGED_PO_FILES: ${{ steps.changed-files.outputs.all_changed_files }} |
| 30 | + GH_TOKEN: ${{ github.token }} |
| 31 | + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |
49 | 32 | run: | |
50 | | - { |
51 | | - echo 'comment<<EOF' |
52 | | - python base-branch/scripts/list_missing_entries.py --github $CHANGED_PO_FILES |
53 | | - echo EOF |
54 | | - } >> "$GITHUB_OUTPUT" |
| 33 | + if [[ ! -f pr-number ]]; then |
| 34 | + echo 'TODO' |
| 35 | + exit 0 |
| 36 | + fi |
| 37 | + pr="$(head -n1 pr-number)" |
| 38 | + if [[ ! "$pr" =~ ^[0-9]+$ ]]; then |
| 39 | + echo 'TODO' |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + actual_sha="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$pr" --jq .head.sha)" |
| 43 | + if [[ "actual_sha" != "$HEAD_SHA" ]]; then |
| 44 | + echo 'TODO' |
| 45 | + exit 0 |
| 46 | + fi |
| 47 | + echo "pr=$pr" >> "$GITHUB_OUTPUT" |
55 | 48 |
|
56 | | - write-comment: |
57 | | - runs-on: ubuntu-22.04 |
58 | | - needs: [define-comment] |
59 | | - if: needs.define-comment.outputs.any_changed == 'true' |
60 | | - permissions: |
61 | | - issues: write |
62 | | - pull-requests: write |
63 | | - steps: |
64 | 49 | - name: Agregar comentario con entradas faltantes |
| 50 | + if: steps.pr.outputs.pr != '' |
65 | 51 | uses: thollander/actions-comment-pull-request@v3 |
66 | 52 | with: |
67 | | - message: ${{ needs.define-comment.outputs.comment }} |
| 53 | + file-path: comment.md |
| 54 | + pr-number: ${{ steps.pr.outputs.pr }} |
68 | 55 | comment-tag: missing-entries |
0 commit comments