-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/automate gh pages publication ptdata1214 (#446)
* add script for automating index.html update * fix - appending at correct version row * adjust to german time * rename file + init tests * rename script + init tests * refactor python * update scripts + add validation rules * init action * add mock ig + update action * add trigger for current branch * update action for manual trigger * Update unzip_and_process_IG_for_archive.yml * add zip * fix action * add test zip * update test names I zip * debug python * test add ig zip * fix update variable * update ig * update action * update ig name * fix filepath * update name * update zip and action wt path fix * delete old mock zip * test * fix * test * test update index * add test zip * add test * fix action + test * added information for PR * test * rm old zip * fix packages removal * fix version for PR * add test * rm * fix variable as step output * test * fix variable * test again * add test * Revert "test update index" This reverts commit 2dda119. * revert index test add for 4.0.0 * Revert "add test" This reverts commit 3ed77b5. * tidy folder * update test as not modifying index.html * fix date format fix redundancy * update description * update * add some changes from review * update action after review * add description * add for action test * update tests * refactor code after review * add todo * update tests * fix test behaviour * clean test set * add action for automated testing * fix * rm feature * fix py install * fix folder * fix test folder * add output as comment * rm print statement * update test * fix * test * test * omit coverate * add gitignore * rm zip * update test + fix script + add gitignore * update gitignore * update gitignore * rm cache
- Loading branch information
1 parent
070ac49
commit 37c8d1b
Showing
7 changed files
with
699 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This action executes the Python test 'test_update_index.py' and outputs the test results whenever a change to the file 'update_index.py' in the 'scripts' folder is pushed to the repository. | ||
|
||
name: Test Python Script for index update | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'scripts/update_index.py' | ||
pull_request: | ||
paths: | ||
- 'scripts/update_index.py' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; else echo "requirements.txt not found"; fi | ||
- name: Run tests | ||
id: run_tests | ||
run: | | ||
python -m unittest discover -s scripts -p 'test_update_index.py' | ||
continue-on-error: true | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Unzip and Update IG Version in webpage | ||
# This GitHub Actions workflow automates the process of unzipping a ZIP file from the IG directory, | ||
# extracting the version number from an HTML file, renaming the directory to the version number, | ||
# removing the packages folder, running a custom Python script to update the index, and creating a pull request | ||
|
||
on: | ||
workflow_dispatch: # Ermöglicht die manuelle Auslösung des Workflows | ||
push: | ||
branches: | ||
- gh-pages | ||
- feature/automate-gh* # TODO remove this line after testing | ||
paths: | ||
- IG/isik-*.zip # Trigger auf das Hinzufügen einer ZIP-Datei im IG-Ordner | ||
|
||
|
||
jobs: | ||
unzip-and-process: | ||
runs-on: ubuntu-latest # Verwende die neueste Ubuntu-Umgebung | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 # Klone das Repository, um auf den Code zuzugreifen | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' # Installiere die neueste Python-Version | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install beautifulsoup4 # Installiere die Abhängigkeit für HTML-Verarbeitung | ||
- name: Unzip file | ||
id: unzip | ||
run: | | ||
# Bestimme die ZIP-Datei und | ||
ZIP_FILE=$(ls IG/isik-*.zip) | ||
# wenn keine Datei gefunden wurde dann brech ab und gibt eine Fehlermdelung aus | ||
if [ -z "$ZIP_FILE" ]; then | ||
echo "No ZIP file found in IG directory" | ||
exit 1 | ||
fi | ||
# prüfe ob mehr als eine Datei dem Schema folgt, falls ja, gib eine Fehlermdelung aus | ||
if [ $(ls IG/isik-*.zip | wc -l) -gt 1 ]; then | ||
echo "Multiple ZIP files found in IG directory" | ||
exit 1 | ||
fi | ||
# Entpacke die zip-Datei in einen Versionsordner namens new-IG | ||
unzip "$ZIP_FILE" -d IG/new-IG | ||
# Entferne die ZIP-Datei, um Konflikte zu vermeiden | ||
rm "$ZIP_FILE" | ||
#lese die Versionsnummer aus der HTML-Datei "ImplementationGuide-markdown-Einfuehrung.html" im neuen Ordner | ||
VERSION=$(grep -oP '(?<=Version: )\d+\.\d+\.\d+' IG/new-IG/ImplementationGuide-markdown-Einfuehrung.html) | ||
#falls die Versionsnummer nicht gefunden wird, gebe eine Fehlermeldung aus und exitiere | ||
if [ -z "$VERSION" ]; then | ||
echo "Version number not found in HTML file" | ||
exit 1 | ||
fi | ||
#benenne den Ordner um in die Versionsnummer und gib die Versionsnummer aus | ||
mv IG/new-IG IG/"$VERSION" | ||
echo "Unzipped version: $VERSION" | ||
# Setze die Versionsnummer als Variable, die später für den python argument input verwendet wird | ||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "VERSION=$VERSION" >> "$GITHUB_ENV" | ||
- name: Remove packages folder | ||
run: | | ||
rm -rf "IG/$VERSION/packages" # Entferne den packages-Ordner aus dem Versionsordner | ||
- name: Run Python script | ||
run: | | ||
python scripts/update_index.py "$VERSION" # Führe das benutzerdefinierte Python-Skript mit der Versionsnummer als Argument aus | ||
- name: Commit changes | ||
run: | | ||
# Konfiguriere Git-Benutzerinformationen für den Commit | ||
git config --local user.name "github-actions" | ||
git config --local user.email "[email protected]" | ||
# Füge alle Änderungen hinzu | ||
git add . | ||
git commit -m "AUTOCOMMIT: Processed ZIP file: $ZIP_FILE" # Erstelle den Commit | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
title: 'AUTOPULLREQUEST: Update from IG folder for TC Version: ${{ steps.unzip.outputs.VERSION }}' # Titel des Pull-Requests | ||
body: 'Automated PULL REQUEST Processed new IG-ZIP file for Version: ${{ steps.unzip.outputs.VERSION }}.' # Beschreibung des Pull-Requests | ||
base: gh-pages # Ziel-Branch für den Pull-Request | ||
branch: update-from-zip-${{ steps.unzip.outputs.VERSION }} # Erstelle einen neuen Branch für die Änderungen mit Angabe der Version |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
*.cpython* | ||
|
||
|
||
# Byte-compiled / optimized / DLL files | ||
scripts/__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# VS Code | ||
.vscode/ | ||
|
||
# JetBrains IDEs | ||
.idea/ | ||
*.iml | ||
*.iws | ||
*.ipr | ||
out/ | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Windows | ||
Thumbs.db | ||
ehthumbs.db | ||
Desktop.ini | ||
$RECYCLE.BIN/ | ||
|
||
# Linux | ||
*~ | ||
|
||
# Logs | ||
*.log | ||
|
||
# Temporary files | ||
*.tmp | ||
*.temp | ||
*.swp | ||
*.swo | ||
*.bak | ||
*.orig | ||
*.save | ||
*.sublime-workspace | ||
*.sublime-project | ||
scripts/__pycache__/test_update_index.cpython-311.pyc | ||
scripts/__pycache__/update_index.cpython-311.pyc |
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
Binary file not shown.
Oops, something went wrong.