# Commits integrate with Backlog issue

We are announcing a new feature of [Backlog GitHub integration action](https://blog.kazamori.jp/backlog-github-integration-action). You can integrate commits in a GitHub repository with Backlog issue.

## Repositories

The repository is here.

* https://github.com/kazamori/backlog-github-integration-action

You can see the test repository and how it works for a quick look.

* https://github.com/kazamori/test-gh-actions-repo

## Usage

Here we show only workflow YAML configuration. See [the previous post](https://blog.kazamori.jp/backlog-github-integration-action#heading-usage) if you need the entire configuration for a newbie to GitHub actions.

This workflow is including two features via `pull_request` event and `push` event. I guess that a user who is interested in our custom action wants to use both. We recommend making an independent workflow file since it's easy to maintain: what the workflow is and add/update a feature/configuration.

```yml
name: Backlog integration

on:
  pull_request:
    types:
      - opened
  push:
    branches:
      - main

jobs:
  backlog-integration:
    runs-on: ubuntu-latest
    env:
      APP_LOCALE: "en_US"
      APP_LOG_LEVEL: "debug"
      BACKLOG_FQDN: ${{ secrets.BACKLOG_FQDN }}
      BACKLOG_API_KEY: ${{ secrets.BACKLOG_API_KEY }}
      BACKLOG_PROJECT_KEY: ${{ secrets.BACKLOG_PROJECT_KEY }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: integrate the pull request with backlog
        if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
        uses: kazamori/backlog-github-integration-action@main
        with:
          subcommand: "pull_request"
          args: "--repository ${{ github.repository }} --pr-number ${{ github.event.number }}"

      - name: integrate commits with backlog
        if: ${{ github.event_name == 'push' }}
        uses: kazamori/backlog-github-integration-action@main
        with:
          subcommand: "push"
          args: "--repository ${{ github.repository }} --pusher ${{ github.event.pusher.name }} --commits '${{ toJson(github.event.commits) }}'"
```

Commits integration is triggered by `push` event. After this workflow run, a user of `BACKLOG_API_KEY` will comment and can change the issue status by commits.

![backlog-issue-comments2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1651311762492/WJDkApJ2E.png align="left")

It's helpful to change the backlog issue status by a commit message.

* fix, fixes, fixed -> Resolved
* close, closes, closed -> Closed

For example, you can change the issue status like this.

```
fix TEST-1
```

```
closed TEST-1
```

## Conclusion

As you can see, our custom action is easy to use. There are only a few features, though.

We can provide more features depending on the developer's needs. We welcome to [discuss them on our repository](https://github.com/kazamori/backlog-github-integration-action/discussions).
