Compare commits

..

18 commits
v2.1.2 ... 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
3 changed files with 192 additions and 49 deletions

View file

@ -1,49 +1,91 @@
- name: Crear release con debug name: Deploy HTML + release
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-22.04
container:
image: catthehacker/ubuntu:act-22.04
volumes:
- /srv/devops/data/apache/htdocs:/output
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Convertir y desplegar
shell: bash
run: | run: |
echo "=== Debug de token ===" chmod +x convertir.sh
if [ -z "$RELEASE_TOKEN" ]; then ./convertir.sh
echo "❌ ERROR: RELEASE_TOKEN está vacío"
# Opcional: copiar a release-dir lo que vaya a ir como asset
rm -rf release-dir
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 exit 1
else
echo "✅ Token presente (longitud: ${#RELEASE_TOKEN})"
fi fi
tag="${GITHUB_REF_NAME}" JSON_PAYLOAD=$(cat <<EOF
{
"tag_name": "${TAG}",
"name": "Release ${TAG}",
"body": "Release automatico",
"draft": false,
"prerelease": false
}
EOF
)
echo "=== Creando release ===" echo "Creando release para tag: ${TAG}"
release_response=$(curl -s -w "\nHTTP:%{http_code}" -X POST \
-H "Authorization: token ${RELEASE_TOKEN}" \ 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\",
\"draft\": false,
\"prerelease\": false
}")
echo "$release_response" echo "Respuesta: ${RESPONSE}"
http_code=$(echo "$release_response" | grep "HTTP:" | cut -d: -f2) RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
echo "Status HTTP: $http_code"
if [ "$http_code" = "201" ]; then if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
release_id=$(echo "$release_response" | grep -v "HTTP:" | jq -r '.id') echo "Error creando release"
echo "✅ Release ID: $release_id"
for file in release-dir/*; do
filename=$(basename "$file")
echo "Subiendo $filename..."
curl -X POST \
-H "Authorization: token ${RELEASE_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${filename}"
done
else
echo "❌ Error creando release"
exit 1 exit 1
fi 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" \
--data-binary @"${FILE}" \
"${FORGEJO_API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
done
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