-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
103 lines (101 loc) · 4.29 KB
/
nightly_build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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", php-version: "7.4"}
- {branch: "main", php-version: "8.1"}
services:
app:
image: "ghcr.io/glpi-project/githubactions-php:${{ matrix.php-version }}"
options: >-
--volume /glpi:/var/glpi
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
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 "build=yes" >> $GITHUB_OUTPUT
else
echo "build=no" >> $GITHUB_OUTPUT
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|/bugfixes||')
echo "basename=$REF_NAME" >> $GITHUB_OUTPUT
SHA=$(git rev-parse --short HEAD)
echo "release_name=$REF_NAME-$SHA" >> $GITHUB_ENV
- name: "Build"
if: ${{ steps.updated.outputs.build == 'yes' }}
run: |
docker exec --interactive ${{ job.services.app.id }} tools/make_release.sh -y . ${{ env.release_name }}
docker cp ${{ job.services.app.id }}:/tmp/glpi-${{ env.release_name }}.tgz ${{ github.workspace }}/${{ env.release_name }}.tar.gz
cp ${{ github.workspace }}/${{ env.release_name }}.tar.gz ${{ github.workspace }}/${{ steps.release-name.outputs.basename }}.tar.gz
- uses: actions/checkout@v4
if: ${{ steps.updated.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.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
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 }}/${{ steps.release-name.outputs.basename }}.tar.gz glpi
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