Compare commits

..

No commits in common. "main" and "v2.0.1" have entirely different histories.
main ... v2.0.1

6 changed files with 23 additions and 172 deletions

View file

@ -1,69 +1,37 @@
name: Deploy HTML + release name: prueba release
on: on:
push: push:
branches: [main] tags:
- 'v*'
jobs: jobs:
deploy: build-and-release:
runs-on: ubuntu-22.04 runs-on: ubuntu-latest # Cambia esto por el label de tu runner
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: Convertir y desplegar - name: Build
shell: bash
run: | run: |
chmod +x convertir.sh mkdir -p dist
./convertir.sh echo "hola release" > dist/mi-artefacto.txt
- name: Obtener ultima tag - name: Create release
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "Última tag encontrada: $TAG"
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Crear release
env: env:
TOKEN: ${{ secrets.RELEASE_TOKEN }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
FORGEJO_API: ${{ github.api_url }}
REPO: ${{ github.repository }}
TAG: ${{ env.TAG }}
run: | run: |
tag="${GITHUB_REF_NAME}"
title="$tag"
RESPONSE=$(curl -s -X POST \ curl -X POST \
-H "Authorization: token ${TOKEN}" \ -H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "${JSON_PAYLOAD}" \ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" \
"${FORGEJO_API}/repos/${REPO}/releases") -d "{
\"tag_name\": \"${tag}\",
echo "Respuesta: ${RESPONSE}" \"name\": \"${title}\",
\"body\": \"Release creado desde Forgejo Actions\",
RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id') \"draft\": false,
\"prerelease\": false
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
[ -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"

View file

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

View file

@ -1,3 +0,0 @@
Este es un documento de prueba.
Tiene varias líneas.
Y será convertido a Markdown.

View file

@ -1,15 +0,0 @@
#!/bin/bash
# Crear directorio para el release
mkdir -p release-dir
# Convertir txt a md (ejemplo simple)
echo "# Documento convertido" > release-dir/documento.md
echo "" >> release-dir/documento.md
cat archivo.txt >> release-dir/documento.md
# Crear archivo de versión
echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
echo "Build completado. Archivos en release-dir/"
ls -lh release-dir/

View file

@ -1,79 +0,0 @@
#!/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 "holaaaa" echo "holaaaaaa"