Skip to content

Commit

Permalink
linting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelsam committed Feb 21, 2024
1 parent 277d48b commit db79215
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Project maintainers have the right and responsibility to remove, edit, or reject

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

The repository holds and shows example usage of the github workflow that can automatically add issues and pull-requests to github projects. The workflow can check labels, project columns, and repository topics to conditionally add issues or pull-requests to selected projects.
The repository holds and shows example usage of the GitHub workflow that can automatically add issues and pull-requests to GitHub projects. The workflow can check labels, project columns, and repository topics to conditionally add issues or pull-requests to selected projects.

### Contents

Expand All @@ -26,25 +26,26 @@ The repository holds and shows example usage of the github workflow that can aut

## Inputs

#### `Projects`
### `Projects`

:thinking: The url of the project to be assigned to.
:thinking: The URL of the project to be assigned to.
You must use one of the follow sets of inputs:
- project
- project1 and/or project2

#### `Topics`
### `Topics`


:thinking: The string of the topics to check for. **Required** if you are using the project1 and/or project 2 inputs.

#### `Column_name`
### `Column_name`

**Optional**: The column name of the project, defaults to `'To do'` for issues and `'In progress'` for pull requests.

## Examples

### Repository project :pencil2:
### Repository project
:pencil2:

```yaml
name: Auto Assign to Project
Expand Down Expand Up @@ -80,7 +81,7 @@ jobs:
#### Notes
:thinking:
Be careful of using the conditions above (opened and labeled issues/PRs) because in such workflow, if the issue/PR is opened and labeled at the same time, it will be assigned to __both__ projects!
Be careful of using the conditions above (opened and labeled issues/PRs) because in such workflow, if the issue/PR is opened and labeled at the same time, it will be assigned to **both** projects!
You can use any combination of conditions. For example, to assign new issues or issues labeled with 'mylabel' to a project column, use:
Expand All @@ -96,7 +97,7 @@ if: |
...
```

### Organization or User project
### Organization or User project
:pencil2:

Generate a token from the Organization settings or User Settings and add it as a secret in the repository secrets as `MY_GITHUB_TOKEN`
Expand Down Expand Up @@ -132,7 +133,7 @@ jobs:
column_name: 'Labeled'
```
### Using topics
### Using topics
:pencil2: Generate a token from the organization settings or User Settings and add it as a secret in the repository secrets as `MY_GITHUB_TOKEN`.
Under 'env:' add the "REPO_URL" variable and use the project1, project2, topic1, and topic2 inputs. If the repository has topic1 then it will be put in project1 and topic2 will be put in project2. If you are using the "column_name" input make sure that both projects have that column.
Expand All @@ -158,8 +159,8 @@ jobs:
uses: Senzing/github-action-add-issue-to-project@1.0.0
with:
project1: 'https://github.com/org/{org-name}/projects/2'
project1: 'https://github.com/org/{org-name}/projects/4'
topic1: 'my-topic1`
project2: 'https://github.com/org/{org-name}/projects/4'
topic1: 'my-topic1'
topic2: 'my-topic2'
column_name: 'Backlog'
```
Expand All @@ -168,6 +169,6 @@ jobs:

1. Github workflow
1. [Documentation](https://docs.github.com/en/rest/reference/actions)
1. [Github actions](https://github.com/features/actions)
1. [GitHub actions](https://github.com/features/actions)
1. Inspiration
1. [GitHub](https://github.com/srggrs/assign-one-project-github-action)
2 changes: 1 addition & 1 deletion docs/errors.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## Errors
# Errors
55 changes: 28 additions & 27 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -l
#!/usr/bin/env bash

PROJECT_URL="$INPUT_PROJECT"
PROJECT1_URL="$INPUT_PROJECT1"
Expand Down Expand Up @@ -61,32 +61,6 @@ get_project_type() {
unset _PROJECT_URL
}

if [ "$PROJECT1_URL" ]; then
_TOPICS=$(curl -s -X GET -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \
-H "Accept: application/vnd.github.mercy-preview+json" \
${REPO_URL})

a=${_TOPICS#*topics}
b=${a#*[}
topics=${b%]*}

if echo "$topics" | grep -q "$TOPIC1"; then
PROJECT_URL=${PROJECT1_URL}

elif [echo "$topics" | grep -q "$TOPIC2"] && ["$PROJECT2_URL"]; then
PROJECT_URL=${PROJECT2_URL}

else
"This repository does not have a matching topic"
exit 1

fi
fi

curl \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/

find_project_id() {
if [ "$PROJECT_URL" ]; then
_PROJECT_TYPE="$1"
Expand Down Expand Up @@ -135,6 +109,33 @@ find_column_id() {
unset _PROJECT_ID _INITIAL_COLUMN_NAME _COLUMNS
}

if [ "$PROJECT1_URL" ]; then
_TOPICS=$(curl -s -X GET -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \
-H "Accept: application/vnd.github.mercy-preview+json" \
${REPO_URL})

a=${_TOPICS#*topics}
b=${a#*[}
topics=${b%]*}

if echo "$topics" | grep -q "$TOPIC1"; then
PROJECT_URL=${PROJECT1_URL}

elif echo "$topics" | grep -q "$TOPIC2" && [ "$PROJECT2_URL" ] ; then
PROJECT_URL=${PROJECT2_URL}

else
"This repository does not have a matching topic"
exit 1

fi
fi

curl \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/


PROJECT_TYPE=$(get_project_type "${PROJECT_URL:?<Error> required this environment variable}")

if [ "$PROJECT_TYPE" = org ] || [ "$PROJECT_TYPE" = user ]; then
Expand Down

0 comments on commit db79215

Please sign in to comment.