Compare commits
No commits in common. "main" and "prueba1" have entirely different histories.
6 changed files with 0 additions and 189 deletions
|
|
@ -1,77 +0,0 @@
|
|||
name: Deploy HTML + release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-22.04
|
||||
volumes:
|
||||
- /srv/devops/data/apache/htdocs:/output
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Convertir y desplegar
|
||||
shell: bash
|
||||
run: |
|
||||
chmod +x convertir.sh
|
||||
./convertir.sh
|
||||
|
||||
- name: Obtener última tag
|
||||
run: |
|
||||
TAG=$(git describe --tags --abbrev=0)
|
||||
echo "TAG=${TAG}" >> $GITHUB_ENV
|
||||
|
||||
- name: Crear release
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
TAG="${env.TAG}"
|
||||
|
||||
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" \
|
||||
-d "${JSON_PAYLOAD}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
|
||||
|
||||
echo "Respuesta: ${RESPONSE}"
|
||||
|
||||
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}..."
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"${FILE}" \
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||
done
|
||||
|
||||
echo "Release completado correctamente"
|
||||
14
archivo.md
14
archivo.md
|
|
@ -1,14 +0,0 @@
|
|||
hola, que tal
|
||||
|
||||
|
||||
|
||||
\- primer intento
|
||||
|
||||
\- segundo intento
|
||||
|
||||
\- tercer intento
|
||||
|
||||
\- con tag
|
||||
|
||||
\- después tag
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Este es un documento de prueba.
|
||||
Tiene varias líneas.
|
||||
Y será convertido a Markdown.
|
||||
15
build.sh
15
build.sh
|
|
@ -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/
|
||||
79
convertir.sh
79
convertir.sh
|
|
@ -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
|
||||
1
test.sh
1
test.sh
|
|
@ -1 +0,0 @@
|
|||
echo "holaaaa"
|
||||
Loading…
Reference in a new issue