Skip to content

Test and deploy

Test and deploy #84

Workflow file for this run

name: Test and deploy
on:
push:
branches:
- main
tags:
- v*
pull_request: {}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dev: ['--dev','']
env:
DEVFLAG: ${{ matrix.dev }}
steps:
- name: Print Docker Compose version
run: |
docker --version
docker-compose --version
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Run thunorbld.py init/testinit
run: |
if [[ $DEVFLAG == "--dev" ]]; then python thunorbld.py init; fi
if [[ $DEVFLAG == "" ]]; then python thunorbld.py testinit; fi
- name: Test suite
run: python thunorbld.py $DEVFLAG test
- name: Upload coverage
if: ${{ matrix.dev == '--dev' }}
run: codecov
deploy:
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Set release or dev mode
id: release_mode
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
echo "::set-output name=qs_branch::dev"
echo "::set-output name=build_tags::alubbock/thunorweb:dev"
else
echo "::set-output name=qs_branch::main"
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}"
echo "::set-output name=build_tags::alubbock/thunorweb:dev,alubbock/thunorweb:latest,alubbock/thunorweb:${GITHUB_REF/refs\/tags\//}"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout Thunor Web
uses: actions/checkout@v2
with:
submodules: true
- name: Checkout Quickstart Repo
uses: actions/checkout@v2
with:
repository: alubbock/thunor-web-quickstart
ref: ${{ steps.release_mode.outputs.qs_branch }}
token: ${{ secrets.API_TOKEN_GITHUB }}
path: thunor-web-quickstart
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: alubbock
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build containers and push
run: python thunorbld.py build --use-buildx --tags=${{ steps.release_mode.outputs.build_tags }} --push
- name: Update and push quickstart repo
run: |
set -e
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
GITHUB_TAG=${GITHUB_REF/refs\/tags\//}
echo "GitHub Tag: $GITHUB_TAG"
fi
cd thunor-web-quickstart
cp ../thunorctl.py .
cp ../docker-compose.services.yml .
cp ../docker-compose.certbot.yml .
rm -rf config-examples
cp -r ../config-examples .
if [ -z "$GITHUB_TAG" ]; then
sed -i 's/thunorweb:latest/thunorweb:dev/' docker-compose.services.yml
echo "$GITHUB_SHA" > .release
else
sed -i "s/thunorweb:latest/thunorweb:$GITHUB_TAG/" docker-compose.services.yml
echo "$GITHUB_TAG" > .release
fi
echo "Contents of .release: $(cat .release)"
git add -A
git status
git config user.email "[email protected]"
git config user.name "GitHub Actions CI"
if [[ $GITHUB_TAG ]]; then
git commit -m "CI update: $GITHUB_TAG"
git tag "$GITHUB_TAG"
git push --tags
# Make another commit referencing "latest" at HEAD
sed -i "s/thunorweb:$GITHUB_TAG/thunorweb:latest/" docker-compose.services.yml
git add docker-compose.services.yml
fi
git commit -m "CI update: $GITHUB_SHA"
git push
cleanup:
needs: deploy
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Delete build image artifact
uses: geekyeggo/delete-artifact@v1
with:
name: thunor-web-container