demyx/mariadb #117
This file contains 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: demyx/mariadb | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '0 0 * * 6' | |
jobs: | |
master: | |
runs-on: ubuntu-latest | |
env: | |
DEMYX_REPOSITORY: mariadb | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Login | |
uses: docker/login-action@v1 | |
with: | |
username: demyx | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build | |
run: | | |
docker pull demyx/nginx | |
docker pull demyx/wordpress | |
docker build -t demyx/${{ env.DEMYX_REPOSITORY }} . | |
- name: Test | |
id: test | |
shell: 'script -q -e -c "bash {0}"' | |
run: | | |
docker network create demyx | |
docker run -d \ | |
--name=${{ env.DEMYX_REPOSITORY }} \ | |
--network=demyx \ | |
-e DEMYX_DATABASE=demyx \ | |
-e DEMYX_USERNAME=demyx \ | |
-e DEMYX_PASSWORD=demyx \ | |
-e DEMYX_ROOT_PASSWORD="$(head /dev/urandom | tr -dc "a-z0-9" | head -c 10 && echo)" \ | |
demyx/${{ env.DEMYX_REPOSITORY }} | |
sleep 10 | |
docker run -d \ | |
--name=demyx_wp \ | |
--network=demyx \ | |
-v demyx_wp:/demyx \ | |
-e DEMYX_DB_HOST=${{ env.DEMYX_REPOSITORY }} \ | |
-e DEMYX_DB_NAME=demyx \ | |
-e DEMYX_DB_USER=demyx \ | |
-e DEMYX_DB_PASSWORD=demyx \ | |
demyx/wordpress | |
sleep 10 | |
docker run -d \ | |
--name=demyx_nx \ | |
--network=demyx \ | |
-v demyx_wp:/demyx \ | |
-e DEMYX_WORDPRESS=true \ | |
-e DEMYX_WORDPRESS_CONTAINER=demyx_wp \ | |
-e DEMYX_WORDPRESS_CONTAINER_PORT=9000 \ | |
-e DEMYX_DOMAIN=localhost \ | |
demyx/nginx | |
sleep 10 | |
DEMYX_TEST="$(docker exec demyx_nx sh -c "wget -qO- http://localhost" 2>&1)" | |
if [[ "$DEMYX_TEST" == *"Hello world"* ]]; then | |
echo "$DEMYX_TEST" | |
else | |
exit 1 | |
fi | |
- name: Version | |
run: | | |
DEMYX_MARIADB_ALPINE_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} cat /etc/os-release | grep VERSION_ID | cut -c 12-)" | |
DEMYX_MARIADB_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} mysql --version | awk -F '[ ]' '{print $6}' | awk -F '[,]' '{print $1}' | sed 's/-MariaDB//g')" | |
DEMYX_JQ="$(jq ".alpine = \"$DEMYX_MARIADB_ALPINE_VERSION\" | .mariadb = \"$DEMYX_MARIADB_VERSION\"" version.json)" | |
# Update versions | |
echo "$DEMYX_JQ" > version.json | |
echo "DEMYX_MARIADB_ALPINE_VERSION=$DEMYX_MARIADB_ALPINE_VERSION | |
DEMYX_MARIADB_VERSION=$DEMYX_MARIADB_VERSION" > VERSION | |
- name: Push | |
run: | | |
# Not sure why this is being created? | |
[[ -f typescript ]] && rm -f typescript | |
DEMYX_CHECK_STATUS="$(git status)" | |
if [[ "$DEMYX_CHECK_STATUS" != *"nothing to commit"* ]]; then | |
DEMYX_RANDOM_QUOTE="$(curl -s "https://api.quotable.io/random?tags=technology" | jq -r '. | "\"\(.content)\" - \(.author)"')" | |
git config --global user.name github-actions[bot] | |
git config --global user.email github-actions[bot]@users.noreply.github.com | |
git remote set-url origin https://demyxsh:${{ secrets.DEMYX_TOKEN }}@github.com/demyxsh/${{ env.DEMYX_REPOSITORY }} | |
git add . | |
git commit -m "${DEMYX_RANDOM_QUOTE:-Scheduled Build}" | |
git push | |
fi | |
docker push demyx/${{ env.DEMYX_REPOSITORY }} |