Skip to content

Commit

Permalink
.some(ts)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Nov 11, 2021
1 parent 8dc5b9a commit 8c809de
Show file tree
Hide file tree
Showing 14 changed files with 973 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:
paths:
- '**/*.ts'
- .github/workflows/ci.yml
jobs:
check-generated-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
env:
NODE_ENV: development
- run: npm run dist
- run: git diff --exit-code
14 changes: 14 additions & 0 deletions .github/workflows/vx-tagger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: vx Tagger
on:
release:
types: [published, edited]
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: sersoft-gmbh/running-release-tags-action@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
update-full-release: true
if: github.event.release.prerelease == false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM node:16-alpine
COPY dist dist
ENTRYPOINT [ "node", "/dist/index.js" ]
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# “New ‘Now Now’” for Git Things Done

This action can be controlled externally to facilitate easy creation of new “Now
Now”s.

## iOS/macOS Shortcuts

We provide shortcuts that you can “duplicate” to facilitate this.

1. [Duplicate]
2. Add to Homescreen/Dock/Menubar
3. Tap/Click to add new items to the “Now Now” list[^1]

<img width="378" alt="image" src="https://user-images.githubusercontent.com/58962/140531618-5012f544-4f25-4815-9978-f3f0e6bf80dd.png">

[Duplicate]: https://www.icloud.com/shortcuts/781d011ddf4748f78ac55d577de3bf20
[^1]: **Please note**, the shortcut will request a [Personal Access Token](https://github.com/settings/tokens) with `repo` scope.

## Desired Features

* Should be *easier* to set up (the PAT is tedious)
* Both the action and our shortcut should support choosing priority


# Setting Up

> ***NOTE*** if you forked our template you will already have this.
You need `.github/workflows/new-now-now.yml` in your [GitTD repo] containing:

```yaml
name: New “Now Now”
on:
repository_dispatch:
types: new-now-now
jobs:
parse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 #FIXME needed so we can get the CURRENT issue
- run: echo "CURRENT=$(git show origin/gh-pages:CURRENT)" >> $GITHUB_ENV
- uses: git-things-done/new-now-now@master
with:
today: ${{ env.CURRENT }}
body: ${{ github.event.client_payload.body }}
token: ${{ secrets.GITHUB_TOKEN }}
```
[GitTD repo]: https://github.com/git-things-done/gtd
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: “New ‘Now Now’” for Git Things Done
description: Creates a new “Now Now”.
inputs:
body:
description: The content for the new “Now Now”.
required: true
today:
description: Today’s issue number.
required: true
token:
description: Typically `{{ secrets.GITHUB_TOKEN }}`
default: ${{ github.token }}
runs:
using: docker
image: Dockerfile
# ^^ because we want node 16 so we can use modern features
8 changes: 8 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
1 change: 1 addition & 0 deletions dist/sourcemap-register.cjs

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { lexer } from 'marked'
import * as github from '@actions/github'
import { getInput } from '@actions/core'
import { exit } from 'process'

const slug = process.env.GITHUB_REPOSITORY!
const [owner, repo] = slug.split('/')
const issue_number = parseInt((getInput('today') || process.env.GTD_TODAY)!)
const token = getInput('token')!
const octokit = github.getOctokit(token)
const body = getInput('body')

const comments = await octokit.rest.issues.listComments({
owner,
repo,
issue_number
})

let out = ''
for (const comment of comments.data) {

//FIXME won’t work if eg. there’s a `# Right Now`
if (!comment.body?.trim().startsWith('# Now Now')) continue;

for (const item of lexer(comment.body)) {
if (item.type === 'heading' && item.text == 'Just Now') {
out = `${out.trim()}
- [ ] ${body.trim()}
`
}
out += item.raw
}

await octokit.rest.issues.updateComment({
owner,
repo,
comment_id: comment.id,
body: out
})

// only once thanks
exit(0)
}

// found nothing, add a new comment
await octokit.rest.issues.createComment({
owner,
repo,
issue_number,
body: `# Now Now\n${body}`
})
Loading

0 comments on commit 8c809de

Please sign in to comment.