Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit a05f74c

Browse files
committed
cleanup, add readme
1 parent e2a275a commit a05f74c

4 files changed

Lines changed: 35 additions & 80 deletions

File tree

.github/workflows/mirror.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "mirror repo projects"
22
on: # run this on a cron schedule
33
schedule:
4-
- cron: '*/3 * * * *'
4+
- cron: '*/5 * * * *'
55
push:
66

77
jobs:

README.md

Lines changed: 33 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,60 @@
22
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
33
</p>
44

5-
# Create a JavaScript Action using TypeScript
5+
# GitHub Projects Column Mirror
66

7-
Use this template to bootstrap the creation of a JavaScript action.:rocket:
7+
This is a GitHub Action to mirror columns in hierarchically modeled GitHub Projects.
88

9-
This template includes compilication support, tests, a validation workflow, publishing, and versioning guidance.
9+
As an example, let's assume a scenario where there are issues used to document both epic and feature level scopes of work, where features belong to epics.
1010

11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
11+
In this scenario, we have two project boards to individually track and give visibility into epics and features individually. Each project board has the following columns:
12+
- backlog
13+
- active
14+
- done
1215

13-
## Create an action from this template
16+
If individual teams, or individual roles within a team, are only looking at the feature board then it can be hard to tell what epics are actively being worked on.
1417

15-
Click the `Use this Template` and provide the new repo details for your action
18+
This action makes this scenario easier by actively mirroring columns across project boards. We can create an `active epics` column on the feature board that will automatically stay up to date with the `active` column on the epics project board.
1619

17-
## Code in Master
20+
## Usage
1821

19-
Install the dependencies
20-
```bash
21-
$ npm install
22-
```
22+
The action is intended to be run on a cron schedule, see [mirror.yml](./.github/workflows/mirror.yml) for an example. The linked action workflow also uses the `push` event trigger for testing purposes only, and is not generally recommended for use.
2323

24-
Build the typescript and package it for distribution
25-
```bash
26-
$ npm run build && npm run pack
2724
```
28-
29-
Run the tests :heavy_check_mark:
30-
```bash
31-
$ npm test
32-
33-
PASS ./index.test.js
34-
✓ throws invalid number (3ms)
35-
wait 500 ms (504ms)
36-
test runs (95ms)
37-
38-
...
25+
on:
26+
schedule:
27+
cron:
28+
# cron actions will not run more frequently than once every 5 minutes
29+
- '*/5 * * * *'
30+
jobs:
31+
mirror_column:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: jonabc/linked-project-columns@<version>
36+
with:
37+
source_column_id: <column node id>
38+
target_column_id: <column node id>
39+
github_token: ${{ secrets.MIRROR_SECRET_PAT }}
3940
```
4041

41-
## Change action.yml
42-
43-
The action.yml contains defines the inputs and output for your action.
44-
45-
Update the action.yml with your name, description, inputs and outputs for your action.
46-
47-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
42+
### Added notice card
4843

49-
## Change the Code
44+
The action will add a notice to the top of the target project column, identifying the source project column and notifying users that the column is automatically managed.
5045

51-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
46+
### Required permissions
5247

53-
```javascript
54-
import * as core from '@actions/core';
55-
...
48+
The `${{ secrets.GITHUB_TOKEN }}` token can be used only when all project columns being accessed live in the target repository. For organization or user owned projects, a personal access token will need to be used that has the following permissions at a minimum:
49+
1. `write:org` to update organization projects
50+
2. `repo` to access information in private repositories
51+
3. `user` to access information in user repositories (if needed)
5652

57-
async function run() {
58-
try {
59-
...
60-
}
61-
catch (error) {
62-
core.setFailed(error.message);
63-
}
64-
}
6553

66-
run()
67-
```
68-
69-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
7054

71-
## Publish to a distribution branch
7255

73-
Actions are run from GitHub repos so we will checkin the packed dist folder.
74-
75-
Then run [ncc](https://github.com/zeit/ncc) and push the results:
76-
```bash
77-
$ npm run pack
78-
$ git add dist
79-
$ git commit -a -m "prod dependencies"
80-
$ git push origin releases/v1
81-
```
8256

83-
Your action is now published! :rocket:
8457

85-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
8658

87-
## Validate
88-
89-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)])
90-
91-
```yaml
92-
uses: ./
93-
with:
94-
milliseconds: 1000
95-
```
9659

97-
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
9860

99-
## Usage:
10061

101-
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

src/main.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ async function ensureCard(
5050

5151
if (!targetCard) {
5252
// add!
53-
core.info(`Creating card in ${targetColumn.name}`)
5453
const cardData: any = {}
5554
if (card.content) {
5655
cardData.contentId = card.content.id
@@ -71,12 +70,10 @@ async function ensureCard(
7170
targetCard = response['addProjectCard'].cardEdge.node
7271
targetColumn.cards.nodes.unshift(targetCard)
7372
targetCardIndex = 0
74-
core.info(`created card: ${targetCard.id}`)
7573
}
7674

7775
if (targetCardIndex !== index) {
7876
// move!
79-
core.info(`moving card: ${targetCard.id}`)
8077
const moveData = {
8178
cardId: targetCard.id,
8279
columnId: targetColumn.id,
@@ -92,8 +89,6 @@ async function ensureCard(
9289
targetColumn.cards.nodes.splice(targetCardIndex, 1)[0]
9390
)
9491
targetCardIndex = index
95-
96-
core.info(`moved card: ${targetCard.id} after ${moveData.afterCardId}`)
9792
}
9893

9994
return targetCard

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"outDir": "./lib", /* Redirect output structure to the directory. */
66
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
77
"strict": true, /* Enable all strict type-checking options. */
8-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
8+
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
99
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
1010
"lib": ["es2020.string"]
1111
},

0 commit comments

Comments
 (0)