Compare commits

...

8 commits

Author SHA1 Message Date
Kristina
f517ef1eed primero etiqueta
Some checks are pending
Deploy HTML + release / deploy (push) Waiting to run
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
4 changed files with 147 additions and 35 deletions

View file

@ -1,52 +1,73 @@
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-latest
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@v3
- 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
release_response=$(curl -s -X POST \ - name: Crear release
-H "Authorization: token $FORGEJO_TOKEN" \ env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
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 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 "{ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/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" RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
echo "Error creando release"
exit 1
fi
echo "Release creado con ID: ${RELEASE_ID}"
for FILE in release-dir/*; do
FILENAME=$(basename "${FILE}")
echo "Subiendo ${FILENAME}..."
# Subir todos los archivos que generó el script
for file in release-dir/*; do
filename=$(basename "$file")
echo "Subiendo $filename al release..."
curl -X POST \ curl -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \ -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}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
done done
echo "Release completado con todos los archivos" echo "Release completado correctamente"

12
archivo.md Normal file
View file

@ -0,0 +1,12 @@
hola, que tal
\- primer intento
\- segundo intento
\- tercer intento
\- con tag

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 "holaaaaa" echo "holaaaa"