Skip to content

demyx/logrotate

demyx/logrotate #80

Workflow file for this run

name: demyx/logrotate
on:
push:
branches:
- master
schedule:
- cron: '0 0 * * 6'
jobs:
master:
runs-on: ubuntu-latest
env:
DEMYX_REPOSITORY: logrotate
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 alpine
docker build -t demyx/${{ env.DEMYX_REPOSITORY }} .
- name: Test
id: test
shell: 'script -q -e -c "bash {0}"'
run: |
docker run -d --name=${{ env.DEMYX_REPOSITORY }} --entrypoint=top demyx/${{ env.DEMYX_REPOSITORY }}
DEMYX_TEST="$(docker exec ${{ env.DEMYX_REPOSITORY }} ${{ env.DEMYX_REPOSITORY }} --version 2>&1)"
if [[ "$DEMYX_TEST" == *"${{ env.DEMYX_REPOSITORY }}"* ]]; then
echo "$DEMYX_TEST"
else
exit 1
fi
- name: Version
run: |
DEMYX_LOGROTATE_ALPINE_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} cat /etc/os-release | grep VERSION_ID | cut -c 12-)"
DEMYX_LOGROTATE_VERSION="$(docker exec ${{ env.DEMYX_REPOSITORY }} ${{ env.DEMYX_REPOSITORY }} --version | head -n 1 | awk -F '[ ]' '{print $2}')"
DEMYX_JQ="$(jq ".alpine = \"$DEMYX_LOGROTATE_ALPINE_VERSION\" | .logrotate = \"$DEMYX_LOGROTATE_VERSION\"" version.json)"
# Update versions
echo "$DEMYX_JQ" > version.json
echo "DEMYX_LOGROTATE_ALPINE_VERSION=$DEMYX_LOGROTATE_ALPINE_VERSION
DEMYX_LOGROTATE_VERSION=$DEMYX_LOGROTATE_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 }}