diff --git a/.github/workflows/auto-update-copyright.yml b/.github/workflows/auto-update-copyright.yml deleted file mode 100644 index c12ce98..0000000 --- a/.github/workflows/auto-update-copyright.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Automate Update Copyright Year -on: - schedule: - - cron: '0 0 1 1 *' # Run the action annually on January 1st - workflow_dispatch: # Allows for manual trigger - -jobs: - update-copyright-year: - permissions: write-all - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Get Current Year - id: get_year - run: | - # Get the current year using shell commands - current_year=$(date +%Y) - echo "CURRENT_YEAR=${current_year}" >> $GITHUB_ENV - - - name: Import GPG key - run: echo $GPG_KEY | base64 --decode | gpg --batch --import - env: - GPG_KEY: ${{ secrets.GPG_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURRENT_YEAR: ${{ env.CURRENT_YEAR }} - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} - GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} - GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} - GIT_AUTHOR_NAME: Pooya Parsa Dadashi - GIT_AUTHOR_EMAIL: pooya_parsa_dadashi@yahoo.com - - - name: Add the custom gpg siging program that passes the passphrase to the gpg CLI - run: | - rm -rf /tmp/gpg.sh - echo '#!/bin/bash' >> /tmp/gpg.sh - echo 'gpg --batch --pinentry-mode=loopback --passphrase $GPG_KEY_PASSPHRASE $@' >> /tmp/gpg.sh - chmod +x /tmp/gpg.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURRENT_YEAR: ${{ env.CURRENT_YEAR }} - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} - GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} - GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} - GIT_AUTHOR_NAME: Pooya Parsa Dadashi - GIT_AUTHOR_EMAIL: pooya_parsa_dadashi@yahoo.com - - - name: Create new branch and commit changes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURRENT_YEAR: ${{ env.CURRENT_YEAR }} - GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} - GPG_KEY_PASSPHRASE: ${{ secrets.GPG_KEY_PASSPHRASE }} - GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} - GIT_AUTHOR_NAME: Pooya Parsa Dadashi - GIT_AUTHOR_EMAIL: pooya_parsa_dadashi@yahoo.com - run: | - # Configure Git for the action - git config --local user.email "pooya_parsa_dadashi@yahoo.com" - git config --local user.name "Pooya Parsa Dadashi" - git config --local commit.gpgsign true - git config --local user.signingkey $GPG_KEY_ID - git config --local gpg.program /tmp/gpg.sh - - - # Create a new branch for the changes - BRANCH_NAME="update_copyright_${{ env.CURRENT_YEAR }}" - echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV - - git switch -c $BRANCH_NAME develop - python .github/workflows/update_copyright.py # Run the Python script - git add . # Ensure all changes are added - git commit -S -m "docs: update copyright year to ${{ env.CURRENT_YEAR }}" - git push -f origin $BRANCH_NAME - - - - name: Create Pull Request Github CLI - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CURRENT_YEAR: ${{ env.CURRENT_YEAR }} - run: | - gh pr create --base develop --head datamweb:$BRANCH_NAME --title "docs: update copyright year to ${{ env.CURRENT_YEAR }}" --body "This pull request updates the copyright year to ${{ env.CURRENT_YEAR }}." --label copyright - - - - - - - - - - - - - - - - - - - - - - diff --git a/.github/workflows/update_copyright.py b/.github/workflows/update_copyright.py deleted file mode 100644 index 84d25a1..0000000 --- a/.github/workflows/update_copyright.py +++ /dev/null @@ -1,40 +0,0 @@ -import datetime -import re - -# Get the current year -current_year = datetime.datetime.now().year -print(current_year) - -# Files to update -files = ["LICENSE", "mkdocs.yml"] - -# Function to update the copyright year -def update_copyright(content): - def replace_years(match): - # Do not update if the text contains "Lonnie Ezell" - if "Lonnie Ezell" in match.group(0): - return match.group(0) - # Otherwise, update the end year to the current year - return f"{match.group(1)}-{current_year}" - - # Replace the last year with the current year - return re.sub(r'(\d{4})-(\d{4})', replace_years, content) - -# Process each file -for file in files: - try: - with open(file, 'r') as f: - content = f.read() - - # Update the file content - updated_content = update_copyright(content) - - with open(file, 'w') as f: - f.write(updated_content) - - print(f"Updated {file} with copyright year {current_year}") - except FileNotFoundError: - print(f"File {file} not found. Skipping...") - except Exception as e: - print(f"An error occurred while processing {file}: {e}") -