Unverified Commit 1ea5c109 authored by Guillaume Bougard's avatar Guillaume Bougard Committed by GitHub
Browse files

ci: nightly builds publishing

parent b7457cbb
......@@ -11,6 +11,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
# build on lower supported version to ensure building tools are compatible with this version
......@@ -26,24 +27,69 @@ jobs:
uses: "actions/checkout@v2"
with:
ref: ${{ matrix.branch }}
- name: "Build if updated during the last 24h"
id: updated
run: |
SHA=$( git rev-parse HEAD )
if [ -n "$( git rev-list -n 1 --after="24 hours" $SHA )" ]; then
echo "::set-output name=build::yes"
else
echo "::set-output name=build::no"
fi
- name: "Deploy source into app container"
if: ${{ steps.updated.outputs.build == 'yes' }}
run: |
sudo cp --no-target-directory --preserve --recursive `pwd` /glpi
sudo chown -R 1000:1000 /glpi
- name: "Install dependencies"
if: ${{ steps.updated.outputs.build == 'yes' }}
run: |
docker exec ${{ job.services.app.id }} composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest
- name: "Define release name"
id: release-name
if: ${{ steps.updated.outputs.build == 'yes' }}
run: |
REF_NAME=$(echo ${{ matrix.branch }} | sed -E 's|/|-|')
echo "::set-output name=base::$REF_NAME"
SHA=$(git rev-parse --short HEAD)
echo "release_name=$REF_NAME.$SHA" >> $GITHUB_ENV
- name: "Build"
if: ${{ steps.updated.outputs.build == 'yes' }}
run: |
echo "Y" | docker exec --interactive ${{ job.services.app.id }} tools/make_release.sh . ${{ env.release_name }}
docker cp ${{ job.services.app.id }}:/tmp/glpi-${{ env.release_name }}.tgz ${{ github.workspace }}/${{ env.release_name }}.tar.gz
- name: "Store archive"
uses: actions/upload-artifact@v2
- uses: actions/checkout@v2
if: ${{ steps.updated.outputs.build == 'yes' }}
with:
name: ${{ env.release_name }}.tar.gz
path: ${{ github.workspace }}/${{ env.release_name }}.tar.gz
repository: ${{ github.repository_owner }}/glpi-project.github.io
token: ${{ secrets.GH_PUBLISHING_TOKEN }}
fetch-depth: 0
path: nightly
- name: "Publish nightly"
if: ${{ steps.updated.outputs.build == 'yes' }}
id: publish-nightly
run: |
EMAIL="$(git log --format='%ae' HEAD^!)"
NAME="$(git log --format='%an' HEAD^!)"
chmod +x tools/github-nightly-description.sh
cd nightly
git config --local user.email "$EMAIL"
git config --local user.name "$NAME"
echo "Removing previous ${{ matrix.branch }} builds"
git filter-branch --prune-empty -f --index-filter 'git rm --cached --ignore-unmatch "glpi/${{ steps.release-name.outputs.basename}}.*.tar.gz"' HEAD
cp -vf "${{ github.workspace }}/${{ env.release_name }}.tar.gz" glpi
# script argument should be the ordered list of builds to index
../tools/github-nightly-description.sh `ls -r glpi/*.tar.gz` >glpi/index.md
echo "Repository status:"
git status
ls -lt glpi
# Prepare commit
echo "Adding GLPI ${{ env.release_name }} build"
git add glpi/*
git commit -m "Add GLPI ${{ env.release_name }} nightly build"
# Force commit
git push --force
git status
shell: bash
env:
FILTER_BRANCH_SQUELCH_WARNING: 1
#!/bin/bash -e
#
# ---------------------------------------------------------------------
# GLPI - Gestionnaire Libre de Parc Informatique
# Copyright (C) 2015-2021 Teclib' and contributors.
#
# http://glpi-project.org
#
# based on GLPI - Gestionnaire Libre de Parc Informatique
# Copyright (C) 2003-2014 by the INDEPNET Development Team.
#
# ---------------------------------------------------------------------
#
# LICENSE
#
# This file is part of GLPI.
#
# GLPI is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GLPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GLPI. If not, see <http://www.gnu.org/licenses/>.
# ---------------------------------------------------------------------
#
cat <<HEADER
---
layout: default
title: GLPI Nightly Builds
---
Built on $( date -u +'%F %H:%M:%S UTC' )
HEADER
for file in $*
do
NAME="${file#glpi/}"
BRANCH="${NAME%.*.tar.gz}"
SIZE=$( stat -c %s "$file" )
cat <<DESCRIPTION
## $BRANCH
Archive|Size
---|---
[$NAME]($NAME)|$SIZE
DESCRIPTION
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment