Skip to content

Commit

Permalink
add workflow to generate md files
Browse files Browse the repository at this point in the history
  • Loading branch information
LizenzFass78851 committed May 15, 2024
1 parent 8517ee9 commit 939190c
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/gen_readme.md.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -e # Beende das Skript bei einem Fehler

# Voreinstellungen
#SUCHVERZEICHNIS=
PATCHTHEFILE=README.md

LINKS=/tmp/$PATCHTHEFILE.txt

# Hole die Links
if [ -e "$LINKS" ]; then
rm "$LINKS"
fi

find ./ -name '*' -type d -maxdepth 1 \
| sed 's#^./##g' \
| sed 's# #%20#g' \
| sed -e '1d' \
| grep -v '.git' \
| sort >> $LINKS


# Lösche die Datei
rm $PATCHTHEFILE


# Erstelle die Datei
# Schicht 1
echo -e '# FritzBox Scripts\n\n\nA collection of tools and scripts with which you can do something in combination with a Fritzbox\n\n## Overview of the scripts and files:' | tee $PATCHTHEFILE

# Die Links
while read line; do
echo "- [$(echo $line | sed 's#%20# #g')](./$line)" >> $PATCHTHEFILE
done < $LINKS
73 changes: 73 additions & 0 deletions .github/workflows/gen_md_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: generate selected *.md files

on:
push:
branches: [ main ]
# paths:
# - '.github/workflows/gen_md_files.yml'
#
# - '.github/scripts/gen_readme.md.sh.sh'

# schedule:
# - cron: '20 12 * * *'
workflow_dispatch:

env:
SCRIPT01: .github/scripts/gen_readme.md.sh
# SCRIPT02:

jobs:
generate-and-deploy:
container:
image: ubuntu:22.04
runs-on: ubuntu-latest
# if: github.repository == ''

steps:
- name: key
id: key
run: |
export KEY="${GITHUB_WORKFLOW%-*}"
echo "key=$KEY" >> $GITHUB_OUTPUT
echo "################################################################" && bash -c "echo KEY=$KEY"
- name: update
run: apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade

- name: install
run: |
DEBIAN_FRONTEND=noninteractive apt-get -y install \
git locales
- name: locale
run: locale-gen en_US.utf8 && locale-gen de_DE.UTF-8 && update-locale

- name: clone
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git clone https://github-actions:$GITHUB_TOKEN@${GITHUB_SERVER_URL##*/}/$GITHUB_REPOSITORY.git $GITHUB_WORKSPACE --branch $GITHUB_REF_NAME
- name: generate
run: |
export LANG=en_US.utf8
[ "${{ github.workflow }}" != "${{ steps.key.outputs.key }}" ] && c=5 || c=1
seq $c | while read x; do echo run ${{ env.SCRIPT01 }} && chmod +x ${{ env.SCRIPT01 }} && ./${{ env.SCRIPT01 }}; done
# seq $c | while read x; do echo run ${{ env.SCRIPT02 }} && chmod +x ${{ env.SCRIPT02 }} && ./${{ env.SCRIPT02 }}; done

- name: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git pull
git add .
git status
git config --local user.name github-actions
git config --local user.email github-actions@github.com
git diff --cached --quiet && exit 0 || git commit -m "docs: Update MD Files"
git config --local credential.helper '!x() { echo "password=$GITHUB_TOKEN"; };x'
git push origin $GITHUB_REF_NAME

0 comments on commit 939190c

Please sign in to comment.