GithubHelp home page GithubHelp logo

isabella232 / action-pr-is-up-to-date Goto Github PK

View Code? Open in Web Editor NEW

This project forked from automattic/action-pr-is-up-to-date

0.0 0.0 0.0 51 KB

[READ ONLY] GitHub Action: check that PRs in the repo are up to date with respect to a tag. This repository is a mirror, for issue tracking and development head to: https://github.com/Automattic/Jetpack/

Home Page: https://github.com/Automattic/jetpack/

License: Other

Shell 100.00%

action-pr-is-up-to-date's Introduction

PR is Up-to-Date

This Github Action will check that PRs in the repo are up to date with respect to a tag.

The idea is to work like GitHub's "Require branches to be up to date before merging" setting, but using one or more tags rather than the HEAD of the target branch.

Example

name: PR is up-to-date
on:
  pull_request_target:
    branches: [ master ]
  push:
    tags: [ latest ]

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - name: Handle pull request
        if: github.event_name != 'push'
        uses: Automattic/action-pr-is-up-to-date@v2
        with:
          token: ${{ secrets.API_TOKEN_GITHUB }}
          tags: latest

      - name: Handle tag push
        if: github.event_name == 'push'
        uses: Automattic/action-pr-is-up-to-date@v2
        with:
          token: ${{ secrets.API_TOKEN_GITHUB }}
          tag: latest

Usage

This action is intended to be triggered by pull_request_target or pull_request targeting the specified branch, and by a push to the specified tags. It will not work for pushes to anything else.

On pull request

- uses: Automattic/action-pr-is-up-to-date@v2
  with:
    # Branch to use. Defaults to the repository's default branch.
    branch:

    # Specify the "context" for the status to set. This is what shows up in the
    # PR's checks list. The default is "PR is up to date".
    status:

    # Specify the "description" when the PR is out of date.
    # The default is "This PR needs a ${{ inputs.branch }} merge or rebase.".
    description-fail:

    # Specify the "description" when the PR is up to date. The default is empty.
    description-ok:

    # Specify the tags that are used for the check, separated by whitespace.
    # The tags must point to commits that are reachable from the input branch.
    # For backwards compatibility, if `tags` is not set but `tag` is, the single tag in `tag` will be used here.
    tags:

    # GitHub Access Token. The user associated with this token will show up
    # as the "creator" of the status check.
    token:

The current pull request will be checked for being up to date with the specified tags. The status check will be set accordingly.

On tag push

- uses: Automattic/action-pr-is-up-to-date@v2
  with:
    # Branch to use. Defaults to the repository's default branch.
    branch:

    # Specify the "context" for the status to set. This is what shows up in the
    # PR's checks list. The default is "PR is up to date".
    status:

    # Specify the "description" when the PR is out of date.
    # The default is "This PR needs a ${{ inputs.branch }} merge or rebase.".
    description-fail:

    # Specify the tag that is used for the check. The tag must point to a commit that
    # is reachable from the input branch.
    tag:

    # Only process PRs that touch a file matching one of these paths (one path per line).
    # Any path format accepted by `git diff` may be used.
    paths:

    # GitHub Access Token. The user associated with this token will show up
    # as the "creator" of the status check.
    token:

All open pull requests targeting the specified branch will be checked for being up to date with the specified tag. Any that are not will have the status check set to a failing status.

Pull requests to process may be filtered by setting paths. In that case, only PRs that affect the specified paths will be processed.

Updating tags

You may update tags manually, for example from the command line with

git tag --force $TAG $COMMIT
git push --force origin $TAG

Or you might use another action to examine pushes to your branch and update the tags accordingly. In that case, you'd want to make sure to use a custom access token as events triggered by the stock GITHUB_TOKEN will not trigger workflows and you'll want this workflow to be triggered by the tag push.

Multiple tags

As of v2, this action supports use of multiple tags. The intended use is for a monorepo where you want separate tags per project.

  • On pull request, you'd analyze the paths affected by the PR to determine which tags apply and pass all relevant tags as tags.
  • On push to any of the tags, you'd pass that tag as tag and set paths to the paths that tag applies to.

Perhaps something like this:

- name: Determine tags for PR or paths for pull request
  id: determine
  run: some-script.sh
- name: Check PR
  if: github.event_name == 'pull_request'
  uses: Automattic/action-pr-is-up-to-date@v2
  with:
    tags: steps.determine.outputs.pr-tags
- name: Check tag push
  if: github.event_name == 'push'
  uses: Automattic/action-pr-is-up-to-date@v2
  with:
    tag: steps.determine.outputs.push-tag
    paths: steps.determine.outputs.push-paths

action-pr-is-up-to-date's People

Contributors

anomiex avatar jeherve avatar kraftbj avatar samiff avatar sdixon194 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.