GitHub Action
Backlog-GitHub integration action
This action helps integrate with Nulab's Backlog via GitHub events.
Here are the features.
- updates a Pull Request link into related issues when it has opened.
- updates commit links into related issues when it has pushed.
For Backlog:
- secrets.BACKLOG_FQDN
- secrets.BACKLOG_API_KEY
- secrets.BACKLOG_PROJECT_KEY
For GitHub, you can use secrets.GITHUB_TOKEN without configuring.
See the below example for detail.
Here is an example.
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@v1
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@v1
with:
subcommand: "push"
args: "--repository ${{ github.repository }} --pusher ${{ github.event.pusher.name }} --commits '${{ toJson(github.event.commits) }}'"
By checking ${{ github.event_name }}
, some subcommands can be included in a single workflow yml. Issue IDs are taken from commit messages.
By default, the pull request link is added to the Description
field. But if your Backlog has a custom field named Pull Requests
(types: Sentence
), set it like this.
with:
subcommand: "pull_request"
args: "--repository ${{ github.repository }} --pr-number ${{ github.event.number }} --custom-field \"Pull Requests\""
You can see an actual example of the test repository to run workflows on GitHub actions.
After these workflows run, a user of BACKLOG_API_KEY
will write the Description
field and the issue comments.
After these workflows run, a user of BACKLOG_API_KEY
will comment and change the issue status by commit messages.
Set environment variables.
export APP_LOCALE="en_US"
export APP_LOG_LEVEL="debug"
export BACKLOG_FQDN="YOUR-SPACE.backlog.com"
export BACKLOG_API_KEY="..."
export BACKLOG_PROJECT_KEY="YOURPROJECT"
export GITHUB_TOKEN="..."
$ ./gradlew run --args="pull_request --repository kazamori/backlog-github-integration-action --pr-number 1"
$ ./gradlew run --args="push --repository kazamori/backlog-github-integration-action --pusher t2y --commits '[{"key": "value", ...}]'"
$ ./gradlew githubClient --args='--repository kazamori/backlog-github-integration-action --pr-number 1'
$ ./gradlew backlogClient --args="--issue-id PROJECT-1"
$ ./gradlew backlogClient --args='--issue-id PROJECT-3 --custom-field "MyTextField" --issue-comment "* comment from REST API"'
$ ./gradlew test --info
To build to a Docker daemon, like this.
$ echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USERNAME --password-stdin
$ ./gradlew jibDockerBuild
Confirm the target image was built.
$ docker images | grep backlog-github-integration-action
ghcr.io/kazamori/backlog-github-integration-action latest e25ab30a1bc0 52 years ago 154MB
Confirm the target image can be run.
$ docker run \
--rm \
--env APP_LOCALE \
--env APP_LOG_LEVEL \
--env BACKLOG_API_KEY \
--env BACKLOG_FQDN \
--env BACKLOG_PROJECT_KEY \
--env GITHUB_TOKEN \
ghcr.io/kazamori/backlog-github-integration-action \
pull_request --repository kazamori/backlog-github-integration-action --pr-number 1
To publish to a Github Packages, like this.
$ echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USERNAME --password-stdin
$ ./gradlew clean jar
$ ./gradlew jib -Djib.container.labels="version.backlog-github-integration-action=$(git rev-parse HEAD)"
Confirm a docker image has the git revision label.
$ docker pull ghcr.io/kazamori/backlog-github-integration-action:latest
$ docker inspect ghcr.io/kazamori/backlog-github-integration-action:latest | jq '.[].Config.Labels'
{
"version.backlog-github-integration-action": "4c97539929bcd3e9af1989fe03e6dbc9b3851d3e"
}