Home

Awesome

github-actions-automate-projects

Docker Automated build License

GitHub Actions adding GitHub Issues & Pull requests to the specified GitHub Project column automatically :recycle:. This GitHub Action is inspired by https://github.com/masutaka/github-actions-all-in-one-project

Usage

GitHub Projects belong to organizations, repositories, and users. This GitHub action currently does not support user-based GitHub Project. For any type of GitHub Projects, you need to change GITHUB_PROJECT_URL and GITHUB_PROJECT_COLUMN_NAME depending on your GitHub Project URL and column name to which you want to add new cards. Create .github/workflows/issues.yml file on your repository and edit like below.

Repository-based project

name: Add a new GitHub Project card linked to a GitHub issue to the specified project column
on: [issues, pull_request]
jobs:
  github-actions-automate-projects:
    runs-on: ubuntu-latest
    steps:
    - name: add-new-issues-to-repository-based-project-column
      uses: docker://takanabe/github-actions-automate-projects:v0.0.1
      if: github.event_name == 'issues' && github.event.action == 'opened'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GITHUB_PROJECT_URL: https://github.com/takanabe/github-actions-automate-projects/projects/1
        GITHUB_PROJECT_COLUMN_NAME: To do
    - name: add-new-prs-to-repository-based-project-column
      uses: docker://takanabe/github-actions-automate-projects:v0.0.1
      if: github.event_name == 'pull_request' && github.event.action == 'opened'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GITHUB_PROJECT_URL: https://github.com/takanabe/github-actions-automate-projects/projects/1
        GITHUB_PROJECT_COLUMN_NAME: To do
  1. Replace the URL set on GITHUB_PROJECT_URL to the URL of your repository project to place issues/pull-requests
  2. Replace the URL set on GITHUB_PROJECT_COLUMN_NAME to the string which your repository project has and want to place issues/pull-requests

Organization-based project

name: Add a new GitHub issue to the specified project column
on: [issues, pull_request]
jobs:
  add-new-issues-to-project-column:
    runs-on: ubuntu-latest
    steps:
    - name: add-new-issues-to-organization-based-project-column
      uses: docker://takanabe/github-actions-automate-projects:v0.0.1
      if: github.event_name == 'issues' && github.event.action == 'opened'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_PERSONAL_TOKEN_TO_ADD_PROJECT }}
        GITHUB_PROJECT_URL: https://github.com/orgs/organization_name/projects/1
        GITHUB_PROJECT_COLUMN_NAME: To Do
  1. Replace the URL set on GITHUB_PROJECT_URL to the URL of your repository project to place issues/pull-requests
  2. Replace the URL set on GITHUB_PROJECT_COLUMN_NAME to the string which your repository project has and want to place issues/pull-requests
  3. Replace the secret set on ${{ secrets.GITHUB_PERSONAL_TOKEN_TO_ADD_PROJECT }} to your personal GitHub token
    1. Create a new personal access token from https://github.com/settings/tokens
    2. Create a new personal access token from https://github.com/organization_name/repository_name/settings/secrets with the value of personal access token you created above
    3. Replace the personal token name from ${{ secrets.GITHUB_PERSONAL_TOKEN_TO_ADD_PROJECT }} to ${{ secrets.YOUR_NEW_PERSONAL_TOKEN }}
    4. Link repositories to the project from https://github.com/orgs/organization_name/projects/1/settings/linked_repositories

User-based project

User-based project is not supported yet

Configurations

Docker images

Docker images for this action are automatically built when master branch is updated or new release tags are created in this repository with latest and corresponded tag names (e.g: v.0.0.1). Please use uses: docker://takanabe/github-actions-automate-projects:v0.0.1 and uses: docker://takanabe/github-actions-automate-projects:latest syntax to use pre-build images for this GitHub Actions.

Environment variables

Environment variableValueDescription
GITHUB_TOKEN${{ secrets.GITHUB_TOKEN }}, ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}An Access token to access your repository and projects. if you use repository-based projects, ${{ secrets.GITHUB_TOKEN }} provides appropriate access privileges to this GitHub action (See). If that is not enough, you need to pass ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} by issuing personal access token with appropriate grants.
GITHUB_PROJECT_URLhttps://github.com/username/reponame/projects/1, https://github.com/orgname/reponame/projects/1, https://github.com/orgs/orgname/projects/1A GitHub Project URL you want to use
GITHUB_PROJECT_COLUMN_NAMEAnything (e.g: To Do)A GitHub Project column name you want to place issues/pull-requests
DEBUGAnything (e.g: true)A flag to produce debug messages for this GitHub Actions if this environment variable exists

Condition with contexts

You can easily detect event contexts and use them in if statements. Here are some lists of the useful contexts for this GitHub action.

Property nameValuesDescription
github.event.actionopened, closed, edited, and so onThe name of actions (references for issues and for pull_request
github.event_nameissues, pull_requestThe name of the event that triggered the workflow run

Development

Build Docker image and update DockerHub

Change IMAGE_NAME, DOCKER_REPO and TAG_NAME in Makefile based on your DockerHub settings.

make

Except for sandbox tag, takanabe/github-actions-automate-projects lists production ready Docker images matching GitHub release tag.

License

Apache 2.0