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,58 +1,32 @@
|
|||
name: Deploy HTML + release
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-22.04
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-22.04
|
||||
volumes:
|
||||
- /srv/devops/data/apache/htdocs:/output
|
||||
|
||||
build-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Convertir y desplegar
|
||||
shell: bash
|
||||
- name: Ejecutar build
|
||||
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
|
||||
cp /output/*.html release-dir/ || true
|
||||
|
||||
- name: Obtener última tag
|
||||
run: |
|
||||
set +e
|
||||
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||
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"
|
||||
echo "# Documento convertido" > release-dir/documento.md
|
||||
echo "" >> release-dir/documento.md
|
||||
cat archivo.txt >> release-dir/documento.md
|
||||
echo "Release $(date +%Y-%m-%d)" > release-dir/version.txt
|
||||
echo "Build completado"
|
||||
ls -lh release-dir/
|
||||
|
||||
- name: Crear release
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
FORGEJO_API: ${{ github.api_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ env.TAG }}
|
||||
run: |
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "No hay TAG definida, no creo release"
|
||||
exit 1
|
||||
fi
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
|
||||
JSON_PAYLOAD=$(cat <<EOF
|
||||
{
|
||||
|
|
@ -71,7 +45,7 @@ jobs:
|
|||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "${JSON_PAYLOAD}" \
|
||||
"${FORGEJO_API}/repos/${REPO}/releases")
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases")
|
||||
|
||||
echo "Respuesta: ${RESPONSE}"
|
||||
|
||||
|
|
@ -85,15 +59,14 @@ jobs:
|
|||
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 \
|
||||
curl -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}"
|
||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
|
||||
done
|
||||
|
||||
echo "Release completado correctamente"
|
||||
Loading…
Reference in a new issue