Compare commits

...

22 commits
v2.0.8 ... main

Author SHA1 Message Date
Kristina
0cc2fa76fe primero tag 6
Some checks failed
Deploy HTML + release / deploy (push) Failing after 20s
2026-05-17 21:56:31 +02:00
Kristina
b1c531861e primero tag 5
Some checks failed
Deploy HTML + release / deploy (push) Failing after 21s
2026-05-17 21:53:31 +02:00
Kristina
9bf5071842 primero tag 4 2026-05-17 21:49:31 +02:00
Kristina
2823a6b8f7 primero tag 2 2026-05-17 21:48:11 +02:00
Kristina
8000a94687 primero tag 1 2026-05-17 21:46:28 +02:00
Kristina
6f1c2d6037 primero tag 2026-05-17 21:45:47 +02:00
Kristina
fe9cf12d4f release + html 6 2026-05-17 21:44:49 +02:00
Kristina
3171fa1363 release + html 5 2026-05-17 21:43:31 +02:00
Kristina
9d3fdbccb2 release + html 4 2026-05-17 21:42:58 +02:00
Kristina
0110ab2633 release + html 3 2026-05-17 21:41:58 +02:00
Kristina
379f817e1e release + html 2 2026-05-17 21:40:53 +02:00
Kristina
36c2a5a228 despues etiqueta
Some checks failed
Deploy HTML + release / deploy (push) Failing after 24s
2026-05-17 21:32:22 +02:00
Kristina
f517ef1eed primero etiqueta
Some checks failed
Deploy HTML + release / deploy (push) Failing after 22s
2026-05-17 21:29:55 +02:00
Kristina
70d19fd022 convertir bueno
Some checks failed
Deploy HTML + release / deploy (push) Failing after 26s
2026-05-17 21:26:08 +02:00
Kristina
a85b6b6e90 html + release
All checks were successful
Deploy HTML + release / deploy (push) Successful in 22s
2026-05-17 21:22:22 +02:00
Kristina
c92b575bf4 prueba release + html 2
Some checks failed
Deploy HTML + release / deploy (push) Failing after 12s
2026-05-17 21:19:43 +02:00
Kristina
dec62a9e70 prueba release + html
Some checks failed
Deploy HTML + release / deploy (push) Failing after 9s
2026-05-17 21:12:33 +02:00
Kristina
f209927867 con token 4
All checks were successful
Build and Release / build-and-release (push) Successful in 7s
2026-05-16 17:39:54 +02:00
Kristina
7e1e41c789 con token 3 2026-05-16 17:37:37 +02:00
Kristina
43c152ac0b con caracteristica
All checks were successful
Build and Release / build-and-release (push) Successful in 8s
2026-05-16 17:32:40 +02:00
Kristina
b1d1465156 con token
All checks were successful
Build and Release / build-and-release (push) Successful in 6s
2026-05-16 17:05:42 +02:00
Kristina
eb71eb8d4d con token 2
All checks were successful
Build and Release / build-and-release (push) Successful in 7s
2026-05-16 17:02:49 +02:00
4 changed files with 180 additions and 40 deletions

View file

@ -1,52 +1,91 @@
name: Build and Release name: Deploy HTML + release
on: on:
push: push:
tags: branches: [main]
- 'v*'
jobs: jobs:
build-and-release: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
container:
image: catthehacker/ubuntu:act-22.04
volumes:
- /srv/devops/data/apache/htdocs:/output
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Ejecutar script de build - name: Convertir y desplegar
run: bash build.sh shell: bash
- name: Crear release con los archivos generados
env:
RELEASE_TOKEN: ${{ secrets.release_token }}
run: | run: |
tag="${GITHUB_REF_NAME}" chmod +x convertir.sh
./convertir.sh
# Crear el release # Opcional: copiar a release-dir lo que vaya a ir como asset
release_response=$(curl -s -X POST \ rm -rf release-dir
-H "Authorization: token $FORGEJO_TOKEN" \ mkdir -p release-dir
cp /output/*.html release-dir/ || true
- name: Obtener última tag
run: |
# Esto falla si no hay tags: crea al menos una antes (v0.1.0, etc.)
TAG=$(git describe --tags --abbrev=0)
echo "Ultima tag encontrada: $TAG"
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Crear release
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
FORGEJO_API: ${{ github.api_url }}
REPO: ${{ github.repository }}
TAG: ${{ env.TAG }}
run: |
if [ -z "$TAG" ]; then
echo "No hay TAG definida, no creo release"
exit 1
fi
JSON_PAYLOAD=$(cat <<EOF
{
"tag_name": "${TAG}",
"name": "Release ${TAG}",
"body": "Release automatico",
"draft": false,
"prerelease": false
}
EOF
)
echo "Creando release para tag: ${TAG}"
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \ -d "${JSON_PAYLOAD}" \
-d "{ "${FORGEJO_API}/repos/${REPO}/releases")
\"tag_name\": \"${tag}\",
\"name\": \"Release ${tag}\",
\"body\": \"Release automático generado por build.sh\",
\"draft\": false,
\"prerelease\": false
}")
echo "$release_response" echo "Respuesta: ${RESPONSE}"
release_id=$(echo "$release_response" | jq -r '.id')
echo "Release creado con ID: $release_id"
# Subir todos los archivos que generó el script RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
for file in release-dir/*; do
filename=$(basename "$file") if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
echo "Subiendo $filename al release..." echo "Error creando release"
curl -X POST \ exit 1
-H "Authorization: token $FORGEJO_TOKEN" \ fi
echo "Release creado con ID: ${RELEASE_ID}"
for FILE in release-dir/*; do
[ -e "$FILE" ] || continue
FILENAME=$(basename "${FILE}")
echo "Subiendo ${FILENAME}..."
curl -s -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @"$file" \ --data-binary @"${FILE}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${filename}" "${FORGEJO_API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
done done
echo "Release completado con todos los archivos" echo "Release completado correctamente"

22
archivo.md Normal file
View file

@ -0,0 +1,22 @@
hola, que tal
\- primer intento
\- segundo intento
\- tercer intento
\- con tag
\- después tag
\- con tag creado de antes
\- segunda prueba
\- tercera prueba
\- cuarta prueba

79
convertir.sh Normal file
View file

@ -0,0 +1,79 @@
#!/bin/bash
# =============================================================================
# convertir.sh — Convierte archivos Markdown a HTML y los publica en Apache
# Proyecto: JAK DevOps — workflow cy.yaml
#
# Requisitos:
# - Ejecutar dentro del job container con /output montado sobre el htdocs de Apache
# - El runner debe tener valid_volumes: ['/srv/devops/data/apache/**']
# =============================================================================
set -euo pipefail
OUTPUT_DIR="/output"
BASE_URL="https://portaljack.freeddns.org"
# -----------------------------------------------------------------------------
dependencies() {
echo "[1/3] Instalando dependencias..."
apt-get update -qq
apt-get install -y -qq pandoc
echo " pandoc $(pandoc --version | head -1 | cut -d' ' -f2) instalado"
}
# -----------------------------------------------------------------------------
convert_to_html() {
echo "[2/3] Convirtiendo Markdown → HTML..."
local converted=0
local errors=0
for md in *.md; do
# Guarda ante glob sin matches (bash con set -u no expande *.md si no hay ficheros)
[ -f "$md" ] || { echo " [WARN] No se encontraron archivos .md en el directorio de trabajo"; return 0; }
local filename="${md%.md}"
echo " Procesando: $md"
if pandoc "$md" \
--standalone \
--metadata title="$filename" \
--highlight-style=tango \
--output "${filename}.html"; then
converted=$((converted + 1))
else
echo " [ERROR] Fallo al convertir: $md"
errors=$((errors + 1))
fi
done
echo " Convertidos: ${converted} | Errores: ${errors}"
[ "$errors" -eq 0 ] || return 1
}
# -----------------------------------------------------------------------------
deploy() {
echo "[3/3] Publicando en Apache..."
local count=0
# Itera solo los HTML generados a partir de los .md presentes (no recoge HTMLs previos del repo)
for md in *.md; do
[ -f "$md" ] || continue
local html="${md%.md}.html"
[ -f "$html" ] || continue
cp "$html" "${OUTPUT_DIR}/"
count=$((count + 1))
echo ""
echo " ${BASE_URL}/${html}"
done
}
# -----------------------------------------------------------------------------
main() {
dependencies
convert_to_html
deploy
}
main

View file

@ -1 +1 @@
echo "holaaaaaa" echo "holaaaa"