Dockerized GitHub Action using Python

What is GitHub Action?

Scripting Time!

from github import Github


git = Github("TOKEN HERE")
user_object = git.get_user()
git_username = user_object.login
user_data = {'username': git_username,
            'git_photo_url': user_object.avatar_url, 
            'git_bio': user_object.bio, 
            'git_email': user_object.email, 
            'git_followers': user_object.followers,
            'git_following': user_object.following,
            'name': user_object.name,
            'latest_updated': str(user_object.updated_at)}

Webpage Building

Dockerized GitHub Action using Python 1

Dockerizing and Creating the Action

FROM python:3

RUN pip install -Iv PyGithub==1.53
COPY ./ /gen_index

ENTRYPOINT ["python", "/gen_index/generate_index.py"]

Final Workflow for Usage

.github/workflows folder.
name: Latest portfolio
on:
  schedule:
      # Runs at the end of every day.
      - cron: '0 0 * * *'
  workflow_dispatch:

jobs:     
  job_1:
    name: update-index-with-project
    runs-on: ubuntu-latest
    steps:
        - uses: actions/checkout@v2
        - uses: kaustubhgupta/[email protected]
          with:
            gh_token: ${{ secrets.TOKEN }} # Create a secret for access token and modify the name as you wish
  
        - uses: test-room-7/action-update-file@v1
          with:
            file-path: |
              index.html
            commit-msg: index file added
            github-token: ${{ secrets.TOKEN }}
name: Latest blog post workflow
on:
  push:  # Everytime index.html is pushed, this action runs and updates the blogs section!
    
jobs:
  update-readme-with-blog:
    runs-on: ubuntu-latest
    steps:
        - uses: actions/checkout@v2
        - uses: gautamkrishnar/blog-post-workflow@master
          with:
            feed_list: <Your feedlist>
            max_post_count: 7
            readme_path: index.html
            template: "$newline <h2 class='h2-blog'><a class='a-lightblue' href=$url>$title</a></h2>$newline <br>"  # Do not change the template as it will not render good results!
            gh_token: ${{ secrets.TOKEN }}

Conclusion

This article has been published from the source link without modifications to the text. Only the headline has been changed.

Source link