Compare commits
No commits in common. "main" and "v2.0.0" have entirely different histories.
6 changed files with 20 additions and 173 deletions
|
|
@ -1,69 +1,34 @@
|
||||||
name: Deploy HTML + release
|
name: Release desde cmd
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build-and-release:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: docker
|
||||||
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 "artefacto" > dist/app.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: |
|
||||||
|
curl -X POST \
|
||||||
RESPONSE=$(curl -s -X POST \
|
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||||
-H "Authorization: token ${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\": \"${GITHUB_REF_NAME}\",
|
||||||
echo "Respuesta: ${RESPONSE}"
|
\"name\": \"${GITHUB_REF_NAME}\",
|
||||||
|
\"body\": \"Release automático\",
|
||||||
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"
|
|
||||||
20
archivo.md
20
archivo.md
|
|
@ -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
|
|
||||||
|
|
||||||
|
|
@ -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