Skip to content

Commit

Permalink
Fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
celloward committed Dec 30, 2020
1 parent 3101dfa commit 6b87c4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# gh-action-autoarchive-stale-cards-for-column
This action allows the archiving of stale project cards in a given Github Project column. Helpful especially for cleaning up columns like "Done"

## Use
- Create a .yml workflow in `.github/workflows` directory of the repo that will run the action.
- Follow the below template to use the action and make sure to fill out all required environment variables.

## Workflow Template
```
name: Archive Stale Done Cards
Expand Down Expand Up @@ -43,6 +39,13 @@ jobs:
# Required: Integer for how many days must have elapsed since the last time this card was touched
days-old: 5
```
## Required Inputs
- `access-token`: Access token for repository. Use `"{{ secrets.GITHUB_TOKEN }}"` to prevent leaking secrets. This may require setting up a token with increased privileges. The token must have `repo` privileges.
- `repository`: String with target repo name (e.g. 'kin/gh-action-autoarchive-issues-for-column' should be 'gh-action-autoarchive-issues-for-column' here)
- `repository-owner`: String with repo owner name only (e.g. 'kin/gh-action-autoarchive-issues-for-column' should be 'kin' here)
- `project-name`: String with name of project the target column is in (case insensitive)
- `column-to-archive`: String with target column name (case insensitive)
- `days-old`: Integer for how many days must have elapsed since the last time each card was touched before archiving

## Contribution
To cotnribute, please open an Issue on the action repo: https://github.com/kin/gh-action-autoarchive-issues-for-column to discuss bugs/modifications.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ outputs:
runs:
using: 'node12'
main: 'index.js'
branding:
icon: 'archive'
color: 'yellow'
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ const run = async () => {
.map(node => node.id)

// Archive those - https://docs.github.com/en/free-pro-team@latest/rest/reference/projects#update-an-existing-project-card
let archivedCards = 0

console.log(`Archiving ${cardIdsToArchive.length} cards`)

cardIdsToArchive.forEach(async (id) => {
try {
Expand All @@ -118,15 +119,13 @@ const run = async () => {
authorization: `bearer ${accessToken}`,
},
})
archivedCards += 1
}
catch(e) {
console.log('archiveCard error: ', e)
return false
}
})

console.log(`Archived ${archivedCards} cards`)
} catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit 6b87c4d

Please sign in to comment.