Skip to content

Commit

Permalink
setup a matrix build
Browse files Browse the repository at this point in the history
  • Loading branch information
unglaublicherdude committed Jun 20, 2024
1 parent 58bb3c9 commit b2d4656
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ on:
branches: ["*"]

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
./get-matrix.sh | tee -a $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -34,7 +45,7 @@ jobs:
env:
CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.VAAS_CLIENT_SECRET }}
run: ./install.sh
run: ./install.sh ${{ matrix.nextcloud_version }}

- name: run tests
env:
Expand Down
46 changes: 46 additions & 0 deletions get-matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

MIN_VERSION=$([[ $(cat appinfo/info.xml) =~ $(echo 'min-version=[^[0-9]]*([0-9]+).*') ]] && echo ${BASH_REMATCH[1]})
MAX_VERSION=$([[ $(cat appinfo/info.xml) =~ $(echo 'max-version=[^[0-9]]*([0-9]+).*') ]] && echo ${BASH_REMATCH[1]})

BASE_TEMPLATE='matrix={"include":[VERSIONS]}'
VERSION_TEMPLATE='{"nextcloud_version":"NEXTCLOUD_VERSION"}'


if [ -z "$MIN_VERSION" ] && [ -z "$MAX_VERSION" ]; then
echo 'matrix={"include":[{"nextcloud_version":"29"}]}'
exit 0
fi

if [ -z "$MIN_VERSION" ] && [ -n "$MAX_VERSION" ] ; then
VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MAX_VERSION/g")
echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g"
exit 0
fi

if [ -n "$MIN_VERSION" ] && [ -z "$MAX_VERSION" ] ; then
VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MIN_VERSION/g")
echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g"
fi

if [ "$MIN_VERSION" -eq "$MAX_VERSION" ]; then
VERSIONS=$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$MIN_VERSION/g")
echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g"
exit 0
fi

if [ "$MIN_VERSION" -gt "$MAX_VERSION" ]; then
echo 'Min version should be less or equal to max version'
exit 1
fi

VERSION_TEMPLATE='{"nextcloud_version":"NEXTCLOUD_VERSION"}'
VERSIONS=""
for i in $(eval echo {$MIN_VERSION..$MAX_VERSION})
do
VERSIONS="$VERSIONS,$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$i/g")"
done
echo $BASE_TEMPLATE | sed "s/VERSIONS/$VERSIONS/g"



4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/bin/bash

NEXTCLOUD_VERSION=${1:-29}

source .env-local || echo "No .env-local file found."

setup_nextcloud () {
echo "setup nextcloud"
docker stop nextcloud-container || echo "No container to stop"
sleep 1
docker run -d --name nextcloud-container --rm --publish 80:80 nextcloud:29
docker run -d --name nextcloud-container --rm --publish 80:80 nextcloud:$NEXTCLOUD_VERSION

until docker exec --user www-data -i nextcloud-container php occ status | grep "installed: false"
do
Expand Down

0 comments on commit b2d4656

Please sign in to comment.