Skip to content

Commit

Permalink
Clean up and maintenance (#17)
Browse files Browse the repository at this point in the history
* Clean up docker smoke test

* Auto merge and auto release depandabot PR's
  • Loading branch information
mietzen authored Sep 7, 2023
1 parent 8b9208a commit faf905e
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 17 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Auto-merge Dependabot
on:
pull_request:
types:
- opened
branches:
- 'main'

permissions:
pull-requests: write
contents: write

jobs:
auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ steps.generate-token.outputs.token }}
pull-request-number: ${{ github.event.pull_request.number }}
merge-method: squash
27 changes: 27 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Auto Release"
on:
pull_request:
types:
- closed

jobs:
auto-release:
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]'
name: "Auto Release"
runs-on: "ubuntu-latest"
steps:
- id: get-version
run: |
LATEST_TAG=$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r '.name')
URL='https://gist.githubusercontent.com/mietzen/cd33efb65f91619201a45ac50dcfc29e/raw/bump-version'
echo "version=v$(wget -qO - ${URL} | bash -s ${LATEST_TAG} minor)" >> $GITHUB_OUTPUT
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: "softprops/action-gh-release@v1"
with:
token: ${{ steps.generate-token.outputs.token }}
tag_name: ${{ steps.get-version.outputs.version }}
generate_release_notes: true
17 changes: 1 addition & 16 deletions Docker/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import logging
from time import sleep
from porkbun_ddns import PorkbunDDNS, cli
from porkbun_ddns import PorkbunDDNS

logger = logging.getLogger('porkbun_ddns')
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -32,21 +32,6 @@
for handler in logger.handlers:
handler.setLevel(logging.DEBUG)

if os.getenv('INTEGRATION_TEST'):
logger.info('\n------------------------------------')
logger.info('INTEGRATION TEST! logger.infoing help menu')
logger.info('------------------------------------\n')
while True:
try:
cli.main(argv=['-h'])
except SystemExit:
pass
finally:
logger.info('\n------------------------------------')
logger.info('Sleeping... {}s'.format(sleep_time))
logger.info('------------------------------------\n')
sleep(sleep_time)

if not all([os.getenv('DOMAIN'), os.getenv('SECRETAPIKEY'), os.getenv('APIKEY')]):
logger.info('Please set DOMAIN, SECRETAPIKEY and APIKEY')
sys.exit(1)
Expand Down
24 changes: 24 additions & 0 deletions Docker/test/integration/assets/entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import logging
from time import sleep
from porkbun_ddns import cli

logger = logging.getLogger('porkbun_ddns')
logger.setLevel(logging.INFO)
logger.propagate = False

sleep_time = int(os.getenv('SLEEP', 300))

logger.info('\n------------------------------------')
logger.info('INTEGRATION TEST!')
logger.info('------------------------------------\n')
while True:
try:
cli.main(argv=['-h'])
except SystemExit:
pass
finally:
logger.info('\n------------------------------------')
logger.info('Sleeping... {}s'.format(sleep_time))
logger.info('------------------------------------\n')
sleep(sleep_time)
4 changes: 3 additions & 1 deletion Docker/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

set -xe

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo "Setup"
docker run -d --rm \
--name porkbun-ddns \
--platform ${PLATFORM} \
--env "INTEGRATION_TEST=1" \
--env "SLEEP=301" \
--volume ${SCRIPT_DIR}/integration/assets/entrypoint.py:/entrypoint.py \
"${DOCKER_USER}/porkbun-ddns:${VERSION}-${ARCH}-${BUILD_NR}"

# Install tools needed for inspect
Expand Down

0 comments on commit faf905e

Please sign in to comment.