primero tag 8
All checks were successful
Build and Release / build-and-release (push) Successful in 6s
All checks were successful
Build and Release / build-and-release (push) Successful in 6s
This commit is contained in:
parent
6a7d65b187
commit
22c5b5e502
1 changed files with 26 additions and 53 deletions
|
|
@ -1,59 +1,33 @@
|
||||||
name: Deploy HTML + release
|
name: Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build-and-release:
|
||||||
runs-on: ubuntu-22.04
|
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@v4
|
||||||
|
|
||||||
- name: Convertir y desplegar
|
- name: Ejecutar build
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
chmod +x convertir.sh
|
|
||||||
./convertir.sh
|
|
||||||
|
|
||||||
# Opcional: copiar a release-dir lo que vaya a ir como asset
|
|
||||||
rm -rf release-dir
|
|
||||||
mkdir -p release-dir
|
mkdir -p release-dir
|
||||||
cp /output/*.html release-dir/ || true
|
echo "# Documento convertido" > release-dir/documento.md
|
||||||
|
echo "" >> release-dir/documento.md
|
||||||
- name: Obtener última tag
|
cat archivo.txt >> release-dir/documento.md
|
||||||
run: |
|
echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
|
||||||
set +e
|
echo "Build completado"
|
||||||
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
ls -lh release-dir/
|
||||||
STATUS=$?
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ $STATUS -ne 0 ] || [ -z "$TAG" ]; then
|
|
||||||
echo "No hay tags en el repositorio, no creo release"
|
|
||||||
exit 0 # o exit 1 si quieres fallar el job
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Ultima tag encontrada: $TAG"
|
|
||||||
echo "TAG=$TAG" >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
- name: Crear release
|
- name: Crear release
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
FORGEJO_API: ${{ github.api_url }}
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
TAG: ${{ env.TAG }}
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$TAG" ]; then
|
TAG="${GITHUB_REF_NAME}"
|
||||||
echo "No hay TAG definida, no creo release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
JSON_PAYLOAD=$(cat <<EOF
|
JSON_PAYLOAD=$(cat <<EOF
|
||||||
{
|
{
|
||||||
"tag_name": "${TAG}",
|
"tag_name": "${TAG}",
|
||||||
|
|
@ -64,36 +38,35 @@ jobs:
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "Creando release para tag: ${TAG}"
|
echo "Creando release para tag: ${TAG}"
|
||||||
|
|
||||||
RESPONSE=$(curl -s -X POST \
|
RESPONSE=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "${JSON_PAYLOAD}" \
|
-d "${JSON_PAYLOAD}" \
|
||||||
"${FORGEJO_API}/repos/${REPO}/releases")
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
|
||||||
|
|
||||||
echo "Respuesta: ${RESPONSE}"
|
echo "Respuesta: ${RESPONSE}"
|
||||||
|
|
||||||
RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
|
RELEASE_ID=$(echo "${RESPONSE}" | jq -r '.id')
|
||||||
|
|
||||||
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
|
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
|
||||||
echo "Error creando release"
|
echo "Error creando release"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Release creado con ID: ${RELEASE_ID}"
|
echo "Release creado con ID: ${RELEASE_ID}"
|
||||||
|
|
||||||
for FILE in release-dir/*; do
|
for FILE in release-dir/*; do
|
||||||
[ -e "$FILE" ] || continue
|
|
||||||
FILENAME=$(basename "${FILE}")
|
FILENAME=$(basename "${FILE}")
|
||||||
echo "Subiendo ${FILENAME}..."
|
echo "Subiendo ${FILENAME}..."
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary @"${FILE}" \
|
--data-binary @"${FILE}" \
|
||||||
"${FORGEJO_API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Release completado correctamente"
|
echo "Release completado correctamente"
|
||||||
Loading…
Reference in a new issue