Skip to content

Commit

Permalink
Add warning banners about manual modifications
Browse files Browse the repository at this point in the history
Update workflow for pypi-publish
  • Loading branch information
dormant-user committed Aug 16, 2024
1 parent 2366deb commit 9cfd20a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
name: pypi-publish

on:
workflow_dispatch:
release:
types: [ published ]
types:
- published
push:
branches:
- main
paths:
- '**/*.py'
workflow_dispatch:
inputs:
dry_run:
description: Dry run mode
required: true
options:
- "true"
- "false"

jobs:
pypi-publisher:
runs-on: thevickypedia-lite
steps:
- name: Set dry-run
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "::notice title=DryRun::Setting dry run to ${{ inputs.dry_run }} for '${{ github.event_name }}' event"
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "::notice title=DryRun::Setting dry run to true for '${{ github.event_name }}' event"
echo "dry_run=true" >> $GITHUB_ENV
else
echo "::notice title=DryRun::Setting dry run to false for '${{ github.event_name }}' event"
echo "dry_run=false" >> $GITHUB_ENV
fi
- uses: thevickypedia/pypi-publisher@v3
env:
token: ${{ secrets.PYPI_TOKEN }}
with:
dry-run: ${{ env.dry_run }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ venv
doc_gen/_build
doc_gen/_static
doc_gen/_templates
build/
NetFuse.egg-info/
5 changes: 4 additions & 1 deletion netfuse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def center_text(text: str) -> str:


HEADER = center_text("Begin NetFuse")
WARNING1 = center_text("Please do not make any manual changes within this section".upper())
WARNING2 = center_text("Any modifications made here will be overwritten".upper())
FOOTER = center_text("End NetFuse")


Expand Down Expand Up @@ -83,14 +85,15 @@ def dump(dry_run: bool, filepath: str, output: str, module: ModuleType) -> None:
host_entries += f"{line}\n"
host_entries = host_entries.strip()
host_entries += "\n\n" + HEADER + "\n"
host_entries += "\n" + "*" * 83 + "\n" + WARNING1 + "\n" + WARNING2 + "\n" + "*" * 83 + "\n\n"
for device in module.attached_devices():
if device.ipv4_address:
host_entries += f"{device.ipv4_address}\t{device.name}\n"
else:
LOGGER.debug(
"%s [%s] does not have an IP address", device.name, device.mac_address
)
host_entries += FOOTER + "\n\n"
host_entries += "\n" + FOOTER + "\n\n"
update_host_file(host_entries, output, dry_run)
if output == settings.etc_hosts:
flush_dns_cache()
Expand Down

0 comments on commit 9cfd20a

Please sign in to comment.