Git Product home page Git Product logo

themuuln / auto-pull-request Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 140 KB

This GitHub Action automates the creation of an empty pull request at scheduled intervals, enabling the triggering of workflows or deployments. The action can be configured to merge the pull request if necessary. Use it to streamline your development and automation processes.

License: MIT License

cicd cron github-actions pull-requests

auto-pull-request's Introduction

Auto Pull Request with Merge

This GitHub Action automates the process of creating a pull request with an empty commit and optionally merging it. This can be useful for triggering workflows or deployments on specific branches at regular intervals.

Auto Pull Request

Usage

Schedule

The action is scheduled to run every 5 minutes. You can adjust the schedule based on your requirements. The current schedule is set as follows:

on:
  schedule:
    - cron: "*/5 * * * *"

Workflow

Create a .github/workflows/auto-pull-request.yml file in your repository with the following content:

name: Auto Pull Request with Merge

on:
  schedule:
    - cron: "*/5 * * * *"

jobs:
  auto_pull_request:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Set Git User Name and Email
        run: |
          git config user.name "themuuln"  # Replace with your GitHub username
          git config user.email "[email protected]"  # Replace with your GitHub email

      - name: Create Empty Pull Request
        run: |
          cd $GITHUB_WORKSPACE
          branch="main"  # Change this to the target branch

          # Generate a unique branch name
          branch_name="auto-pull-request-$(date +%s)"

          # Create a new branch
          git checkout -b $branch_name

          # Create an empty commit to trigger a pull request
          git commit --allow-empty -m "Auto Pull Request Trigger"

          # Push the new branch to the repository
          git push origin $branch_name

          # Create the pull request using your GitHub credentials
          pr_url=$(curl -X POST -u "YourGitHubUsername:$PERSONAL_ACCESS_TOKEN" -d '{
            "title": "Automated Pull Request",
            "head": "'$branch_name'",
            "base": "'$branch'"
          }' "https://api.github.com/repos/USERNAME/REPO_NAME/pulls")

          # Merge the pull request (if needed) using your GitHub credentials
          curl -X PUT -u "YourGitHubUsername:$PERSONAL_ACCESS_TOKEN" "$pr_url/merge"
        env:
          PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Make sure to replace the placeholder values (YourGitHubUsername, USERNAME, REPO_NAME) with your actual GitHub username and repository details.

Personal Access Token

To securely use your GitHub credentials, create a personal access token and add it as a secret named PERSONAL_ACCESS_TOKEN in your GitHub repository settings.

Now, every 5 minutes, this workflow will create an empty pull request on the specified branch, triggering any associated workflows or deployments. Optionally, it can merge the pull request based on your configuration. Adjust the branch names and other details as needed for your specific use case.

auto-pull-request's People

Contributors

themuuln avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.