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 b9a5f7a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/release-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ on:
branches: ["*"]

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
nextcloud_versions: ${{ steps.get-matrix.outputs.nextcloud_versions }}
steps:
- uses: actions/checkout@v4
- id: get-matrix
run: echo "nextcloud_versions=$(./get-matrix.sh)" >> "$GITHUB_OUTPUT"

test:
runs-on: ubuntu-latest
strategy:
matrix:
nextcloud_version: ${{fromJson(needs.matrix.outputs.nextcloud_versions)}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -34,7 +46,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
50 changes: 50 additions & 0 deletions get-matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/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='[VERSIONS]'
VERSION_TEMPLATE='"NEXTCLOUD_VERSION"'

if [ -z "$MIN_VERSION" ] && [ -z "$MAX_VERSION" ]; then
echo '["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

VERSIONS=""
FIRST_RUN="YES"
for i in $(eval echo {$MIN_VERSION..$MAX_VERSION})
do
if [ "$FIRST_RUN" == "YES" ]; then
VERSIONS="$(echo $VERSION_TEMPLATE | sed "s/NEXTCLOUD_VERSION/$i/g")"
FIRST_RUN="NO"
continue
fi
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 b9a5f7a

Please sign in to comment.