Formatear Formularios #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Formatear Formularios | |
on: | |
workflow_dispatch: | |
inputs: | |
ref_commit: | |
description: 'Commit de referencia, puede ser HEAD o similar' | |
push: | |
paths: | |
- "formularios/*.md" | |
pull_request: | |
paths: | |
- "formularios/*.md" | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Acondicionar git # Necesario para que git diff funcione correctamente con archivos UTF-8 | |
run: git config --global core.quotepath off | |
- uses: actions/checkout@v4.1.2 | |
with: | |
fetch-depth: 15 | |
- name: Agregar bloques de código a los formularios | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] | |
then | |
IFS=$'\n' read -r -d '' -a files < <( git diff --name-only ${{ github.event.inputs.ref_commit }} HEAD && printf '\0' ) | |
else | |
IFS=$'\n' read -r -d '' -a files < <( git diff --name-only ${{ github.event.before }} ${{ github.sha }} && printf '\0' ) | |
fi | |
for file in "${files[@]}" | |
do | |
if [[ $file == *.md && -f "$file"]] | |
then | |
python .github/scripts/agregar_bloque_math.py "$file" | |
fi | |
done | |
- uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: "workflow(formularios): Agregar bloques de código" | |
- name: Prettify code | |
uses: creyD/prettier_action@v4.3 | |
with: | |
prettier_options: "--write **/*.md" | |
commit_message: "estilo{.md}: Prettier" |