Skip to content

raf262/github-action-try

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github Actions on a simple Symfony skeleton

License: CC BY-NC-ND 4.0

Note: This project is created on an R&D day to add github actions to our projects. It is based on a Symfony skeleton and allow you to have basic Github Actions preconfigured for your project including :

  • Linter checker on PR
  • Adding reviewers on PR
  • Stale and close PR / Issue if no activity > 30days

You might have to create new labels in your Github environment and change some variables in jobs for your projects.

Structure

Github Actions are located under a folder at the project's root

./.github/workflow/        

Install

Github actions are automatically loaded from your project's files. If you delete the file, the Action will be deleted.

Usage

Create a new file in ./.github/workflow/ name my_github_action.yml. It will contain :

  • a node name displayed on the tab Actions on your Github repository
  • a node on that configure when the actions will be triggered
  • then a node jobs who contains the actions to run when doing the job
name: 'My super Github Action'
on:
  pull_request:
    types: [opened, ready_for_review]

jobs:
  add-reviews:
    runs-on: ubuntu-latest
    steps:
      - uses: package/action@version
        with:
          configuration-path: ".github/conf.yml"

Jobs

Linter checker

This job runs a linter checker on the project. It is triggered on every push in the project excluding the master and main branches. It use the github/super-linter action. Only new edited or added files are analysed. The ./vendor directory, files @generated and .gitignore are excluded from the analysis.

Stale checker

This job act as a CRON job and check if a PR or an Issue is still active. If she's not, it will add a tag stale and close the PR or Issue in 5 or 10 days depending on your configuration. You can set a predefined message for the PR or Issue that is stale. Change the number of day without activity before staled, exempt PR with some label and start analysing PR / Issue opened after a certain date with start_date. It use the actions/stale@v4.

Add reviewers

This job auto add reviewers to the PR using a configuration file located at ./github/teams/my-team.yml. It is triggered when a pull request is open and ready for review. It is base on kentaro-m/auto-assign-action@v1.2.0. In the configuration file of your team you can assign the PR directly to the creator (done by default). The name of the reviewer that you set in :

reviewGroups:
    my-team:
        - reviewer_name_1
        - reviewer_name_2

will automatically be added to your PR.

Branch name Pull Request

This job check if your Pull Request title respect the conventions. You can change the parameters to mirror your own conventions. It is only trigger on pull request otherwise it would fail. This job use deepakputhraya/action-pr-title@master.

Regex : ^(revert: )?(build|chore|docs|feat|fix|perf|refactor|style|test)(\(.*\))?: .{1,50}

Send slack messages

This job runs on every pull request. It checks that the PR's number is a modulo of 100 so the author had to bring 🥐 to the team. The message is sent to a slack channel that need to be set in the job file. Either a slack token need to be set in the repository variable in github. This job runs on hbfernandes/slack-action@1.0.

Security

If you discover any security related issues, please use the issue tracker.

Credits

About

Implement github action on project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published