Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
feat: converted main.workflow to Actions V2 yml files (#19)
Browse files Browse the repository at this point in the history
Switch to GitHub Actions V2 syntax (YAML) and fix neutral exit code to succeed when nothing to do.
  • Loading branch information
lusoalex committed Aug 27, 2019
1 parent 5fb1db2 commit 640902e
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 57 deletions.
45 changes: 0 additions & 45 deletions .github/main.workflow

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: milestone
name: Milestone Closure
jobs:
action-filter:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- name: action-filter
uses: actions/bin/filter@master
with:
args: action closed
- name: Create Release Notes
uses: docker://decathlon/release-notes-generator-action:1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OUTPUT_FOLDER: temp_release_notes
USE_MILESTONE_TITLE: "true"
- name: Upload Release Notes to Wiki
uses: docker://decathlon/wiki-page-creator-action:1.0.0
env:
ACTION_MAIL: oss@decathlon.com
ACTION_NAME: decathlonbot
GH_PAT: ${{ secrets.GH_PAT }}
MD_FOLDER: temp_release_notes
OWNER: decathlon
REPO_NAME: pull-request-labeler-action
SKIP_MD: README.md
13 changes: 13 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on: pull_request
name: Auto Label Pull Request
jobs:
pRLabelByFiles:
name: PR label by Files
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- name: PR label by Files
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG_PATH: ${{ secrets.GITHUB_WORKSPACE }}/.github/label-pr.yml
62 changes: 54 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Github auto-labeler action
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgit.luolix.top%2FDecathlon%2Fpull-request-labeler-action.svg?type=shield)](https://app.fossa.io/projects/git%2Bgit.luolix.top%2FDecathlon%2Fpull-request-labeler-action?ref=badge_shield)
[![CircleCI](https://circleci.com/gh/Decathlon/pull-request-labeler-action/tree/master.svg?style=svg)](https://circleci.com/gh/Decathlon/pull-request-labeler-action/tree/master)

GitHub actions to auto label a pull request based on committed files.

<p align="center">
<img src="https://github.com/Decathlon/pull-request-labeler-action/raw/master/assets/intro.png" alt="Result illustration"/>
<img src="https://github.com/Decathlon/pull-request-labeler-action/raw/master/assets/intro.png" alt="Result illustration"/><br>
<a href="https://app.fossa.io/projects/git%2Bgit.luolix.top%2FDecathlon%2Fpull-request-labeler-action?ref=badge_shield"><img src="https://app.fossa.io/api/projects/git%2Bgit.luolix.top%2FDecathlon%2Fpull-request-labeler-action.svg?type=shield"></a>
<a href="https://circleci.com/gh/Decathlon/pull-request-labeler-action/tree/master"><img src="https://circleci.com/gh/Decathlon/pull-request-labeler-action.svg?style=svg"></a>
<br><br>
This repository provides a GitHub action to <strong>automatically label a pull request</strong> based on committed files.
</p>

**Table of Contents**

- [Common usage](#common-usage)
- [Breaking change](#breaking-change)
- [Startup](#startup)
- [Configuration](#configuration)
- [Use Github action](#use-github-action)
- [Settings for v1.0.0+ release (deprecated)](#settings-for-v100-release-deprecated)
- [Settings for v2.0.0+ release](#settings-for-v200-release)
- [Contributing](#contributing)
- [Commands](#commands)
- [License](#license)

## Common usage

When pushing, the action will be triggered and will look for committed files over your branch.
It applies configured labels whenever it find a file whose name matches the associated regular expression.

Expand All @@ -16,6 +29,13 @@ It applies configured labels whenever it find a file whose name matches the asso
<img src="https://github.com/Decathlon/pull-request-labeler-action/raw/master/assets/log.png" alt="Action log messages"/>
</p>

## Breaking change

Starting from August 2019, GitHub switch [Actions syntax from HCL to YAML](https://help.github.com/en/articles/migrating-github-actions-from-hcl-syntax-to-yaml-syntax).
The previous syntax will no longer be supported by GitHub on September 30, 2019.

As a consequence, __please use v2.0.0+__ release and note that __all v1.x.x are deprecated__ and will no longer work on September 30, 2019.

## Startup

### Configuration
Expand Down Expand Up @@ -43,6 +63,8 @@ If the labels do not exist yet in your repository configuration, they will be cr

### Use Github action

#### Settings for v1.0.0+ release (deprecated)

Create a file into your root project directory (if it does not exist yet): `.github/main.workflow`:
```
workflow "New workflow" {
Expand All @@ -56,7 +78,31 @@ action "PR label by Files" {
}
```

When configuring the action, you need to provide the right link into `uses` field here.
#### Settings for v2.0.0+ release

Create a file into your root project directory: `.github/workflows/labeler.yml`:
```yaml
# Workflow to associate labels automatically
name: labeler
# Trigger the workflow on pull request events
on: [pull_request]
jobs:
label:
runs-on: ubuntu-18.04
steps:
# We need to checkout the repository to access the configured file (.github/label-pr.yml)
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Labeler
uses: docker://decathlon/pull-request-labeler-action:2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Here we can override the path for the action configuration. If none is provided, default one is `.github/label-pr.yml`
CONFIG_PATH: ${{ secrets.GITHUB_WORKSPACE }}/.github/label-pr.yml
```

_Please note that you can move the label-pr.yml to another location, if so, then do not forget to update the above **CONFIG_PATH**_ variable.

## Contributing

Expand Down
9 changes: 5 additions & 4 deletions src/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const getLabelsToAdd = (labels: string[], issueLabels: string[], {log, exit}: To
const labelsToAdd: string[] = intersectLabels(labels, issueLabels);
log.info('Labels to add: ', labelsToAdd);
if (labelsToAdd.length === 0) {
exit.neutral("No labels to add");
exit.success("No labels to add");
}
return labelsToAdd;
};
Expand All @@ -96,7 +96,8 @@ Toolkit.run(async (toolkit: Toolkit) => {
toolkit.log.info('Open sourced by\n' + LOGO);

toolkit.log.info('Running Action');
const filters: Filter[] = toolkit.config('.github/label-pr.yml');
const configPath: string = process.env.CONFIG_PATH ? process.env.CONFIG_PATH : '.github/label-pr.yml';
const filters: Filter[] = toolkit.config(configPath);
toolkit.log.info(" Configured filters: ", filters);

if (!process.env.GITHUB_EVENT_PATH) {
Expand All @@ -123,8 +124,8 @@ Toolkit.run(async (toolkit: Toolkit) => {
}
)
.then((addLabelsParams: IssuesAddLabelsParams) => issues.addLabels(addLabelsParams))
.then((value: Response<IssuesAddLabelsResponseItem[]>) => toolkit.log.info(`Adding label status: ${value.status}`))
.catch(reason => toolkit.exit.failure(reason));
.catch(reason => toolkit.exit.failure(reason))
.then((value: Response<IssuesAddLabelsResponseItem[]>) => toolkit.log.info(`Adding label status: ${value.status}`));
}
toolkit.exit.success('Labels were update into pull request')
},
Expand Down

0 comments on commit 640902e

Please sign in to comment.