|
| 1 | +name: Generate readme file on push |
| 2 | +run-name: Generating readme file |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | +jobs: |
| 8 | + Generate-readme-file: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: write |
| 12 | + steps: |
| 13 | + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." |
| 14 | + - name: check out repository code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + ssh-key: ${{ secrets.DEPLOY_KEY }} |
| 18 | + ref: main |
| 19 | + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." |
| 20 | + - name: Remove previous readme file |
| 21 | + run: rm ${{ github.workspace }}/README.md |
| 22 | + - name: List files in the repository |
| 23 | + run: | |
| 24 | + ls ${{ github.workspace }} |
| 25 | + - name: setup python |
| 26 | + uses: actions/setup-python@v4 |
| 27 | + with: |
| 28 | + python-version: '3.10' |
| 29 | + - name: install python packages |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + - name: execute py script |
| 33 | + run: python other/scripts/readme_generator.py |
| 34 | + - name: check for changes |
| 35 | + run: | |
| 36 | + if [[ -n $(git status --porcelain) ]]; then |
| 37 | + echo "FILES_CHANGED=true" >> $GITHUB_ENV |
| 38 | + else |
| 39 | + echo "FILES_CHANGED=false" >> $GITHUB_ENV |
| 40 | + fi |
| 41 | + - name: Get current date |
| 42 | + id: date |
| 43 | + run: echo "BUILD_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV |
| 44 | + - name: commit and push files |
| 45 | + if: env.FILES_CHANGED == 'true' |
| 46 | + run: | |
| 47 | + git config --local user.email "[email protected]" |
| 48 | + git config --local user.name "GitHub Action" |
| 49 | + git add . |
| 50 | + git commit -m "Automatic creation of readme file after commit on main branch on $BUILD_TIME" |
| 51 | + git push |
| 52 | + - run: echo "Job finished with status ${{ job.status }}." |
0 commit comments