|
2 | 2 | <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> |
3 | 3 | </p> |
4 | 4 |
|
5 | | -# Create a JavaScript Action using TypeScript |
| 5 | +# GitHub Projects Column Mirror |
6 | 6 |
|
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. |
8 | 8 |
|
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. |
10 | 10 |
|
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 |
12 | 15 |
|
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. |
14 | 17 |
|
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. |
16 | 19 |
|
17 | | -## Code in Master |
| 20 | +## Usage |
18 | 21 |
|
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. |
23 | 23 |
|
24 | | -Build the typescript and package it for distribution |
25 | | -```bash |
26 | | -$ npm run build && npm run pack |
27 | 24 | ``` |
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 }} |
39 | 40 | ``` |
40 | 41 |
|
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 |
48 | 43 |
|
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. |
50 | 45 |
|
51 | | -Most toolkit and CI/CD operations involve async operations so the action is run in an async function. |
| 46 | +### Required permissions |
52 | 47 |
|
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) |
56 | 52 |
|
57 | | -async function run() { |
58 | | - try { |
59 | | - ... |
60 | | - } |
61 | | - catch (error) { |
62 | | - core.setFailed(error.message); |
63 | | - } |
64 | | -} |
65 | 53 |
|
66 | | -run() |
67 | | -``` |
68 | | - |
69 | | -See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. |
70 | 54 |
|
71 | | -## Publish to a distribution branch |
72 | 55 |
|
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 | | -``` |
82 | 56 |
|
83 | | -Your action is now published! :rocket: |
84 | 57 |
|
85 | | -See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) |
86 | 58 |
|
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 | | -``` |
96 | 59 |
|
97 | | -See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket: |
98 | 60 |
|
99 | | -## Usage: |
100 | 61 |
|
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 |
0 commit comments