GLPI nightly build #1994
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "GLPI nightly build" | |
| on: | |
| # Runs test suite every night | |
| schedule: | |
| - cron: '0 0 * * *' | |
| # Enable manual run | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| permissions: | |
| contents: write # for Git to git push | |
| if: github.repository == 'glpi-project/glpi' | |
| name: "Build ${{ matrix.branch }}" | |
| 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 | |
| - {branch: "10.0/bugfixes", version-name: "10.0", php-version: "7.4"} | |
| - {branch: "11.0/bugfixes", version-name: "11.0", php-version: "8.2"} | |
| - {branch: "main", version-name: "dev", php-version: "8.2"} | |
| services: | |
| app: | |
| image: "ghcr.io/glpi-project/githubactions-php:${{ matrix.php-version }}" | |
| options: >- | |
| --volume /glpi:/var/www/glpi | |
| steps: | |
| - name: "Checkout" | |
| uses: "actions/checkout@v5" | |
| with: | |
| ref: ${{ matrix.branch }} | |
| - name: "Define variables" | |
| id: vars | |
| run: | | |
| SHA=$( git rev-parse HEAD ) | |
| if [ -n "$( git rev-list -n 1 --after="24 hours" $SHA )" ]; then | |
| echo "build=yes" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=no" >> $GITHUB_OUTPUT | |
| fi | |
| REF_NAME=$(echo ${{ matrix.version-name }}) | |
| SHA=$(git rev-parse --short HEAD) | |
| echo "release_name=$REF_NAME-$SHA" >> $GITHUB_OUTPUT | |
| - name: "Deploy source into app container" | |
| if: ${{ steps.vars.outputs.build == 'yes' }} | |
| run: | | |
| sudo cp --no-target-directory --preserve --recursive `pwd` /glpi | |
| sudo chown -R 1000:1000 /glpi | |
| - name: "Install dependencies" | |
| if: ${{ steps.vars.outputs.build == 'yes' }} | |
| run: | | |
| docker exec ${{ job.services.app.id }} composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest | |
| - name: "Build" | |
| if: ${{ steps.vars.outputs.build == 'yes' }} | |
| run: | | |
| docker exec --interactive ${{ job.services.app.id }} tools/make_release.sh -y . ${{ steps.vars.outputs.release_name }} | |
| docker cp ${{ job.services.app.id }}:/tmp/glpi-${{ steps.vars.outputs.release_name }}.tgz ${{ github.workspace }}/${{ steps.vars.outputs.release_name }}.tar.gz | |
| cp ${{ github.workspace }}/${{ steps.vars.outputs.release_name }}.tar.gz ${{ github.workspace }}/${{ matrix.version-name }}.tar.gz | |
| - uses: actions/checkout@v5 | |
| if: ${{ steps.vars.outputs.build == 'yes' }} | |
| with: | |
| repository: ${{ github.repository_owner }}/glpi-project.github.io | |
| token: ${{ secrets.GH_PUBLISHING_TOKEN }} | |
| fetch-depth: 0 | |
| path: nightly | |
| - name: "Publish nightly" | |
| if: ${{ steps.vars.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/${{ matrix.version-name }}.tar.gz"' HEAD | |
| git filter-branch --prune-empty -f --index-filter 'git rm --cached --ignore-unmatch "glpi/${{ matrix.version-name }}-*.tar.gz"' HEAD | |
| cp -vf ${{ github.workspace }}/${{ matrix.version-name }}.tar.gz glpi | |
| cp -vf ${{ github.workspace }}/${{ steps.vars.outputs.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 ${{ steps.vars.outputs.release_name }} build" | |
| git add glpi/* | |
| git commit -m "Add GLPI ${{ steps.vars.outputs.release_name }} nightly build" | |
| # Force commit | |
| git push --force | |
| git status | |
| shell: bash | |
| env: | |
| FILTER_BRANCH_SQUELCH_WARNING: 1 |