Categorygithub.com/mrflynn/notion-auto-archive
modulepackage
0.1.0
Repository: https://github.com/mrflynn/notion-auto-archive.git
Documentation: pkg.go.dev

# README

Notion Auto-Archive

Tests

Automatically archives old tasks on a Notion task board. This is to prevent your column of completed tasks from getting filled with old tasks.

Getting Started

First, you will need to get an API key and the ID(s) of the task board(s) you wish to manage with this application. Notion has a pretty good guide on how to get that information.

Next, you will need to create a configuration file. You can name if whatever you want, but in this example I'll call it config.yml. The configuration file has the following format.

apiKey: <api-key> # Can set using CLI or environment variables.
boards:
  - id: <board-id>
    archiveAfter: 24h
    selectors:
      columnName: Status
      sourceColumn: Completed
      targetColumn: Archived
  # More boards go here.

See the section titled Configuration Options for more details on what each option does.

Downloading the Application

Head to the releases page and grab a copy of the application for your platform, or you can use one of the following alternative methods. Extract the downloaded binary and add it to your path.

Using Go

You can run go get github.com/mrflynn/notion-auto-archive and it will download and build the latest release of the application.

Using Docker

This application is also available through Docker. The Docker image is available on all of the same platforms that the binaries are available on. Just run docker pull ghcr.io/mrflynn/notion-auto-archive:latest to get the latest Docker image.

Running the Application

Using a Binary

Simply run the executable you downloaded with the following flags.

$ notion-auto-archive -config=/path/to/config.yml

You can specify the -key flag if your API key is not in your configuration file, or by setting the NOTION_AUTO_ARCHIVE_API_KEY environment variable.

Using Docker

Similarly, you can run the Dockerfile as follows.

$ docker run --rm --name notion-auto-archive \
    -v /path/to/config.yml:/config.yml:ro \
    ghcr.io/mrflynn/notion-auto-archive:latest

Refer to Docker's docs for how to set environment variables or change CLI flags.

Configuration Options

The table below describes all of the configuration fields found in config.yml.

OptionDefault ValueDescription
apiKeyEmpty stringNotion.so API key. Can also be set using CLI or environment variable.
boardsEmpty arrayList of task board this application will manage.
boards.idEmpty stringID of board.
boards.archiveAfter24hAfter how much time of inactivity should the task be moved. Must be in seconds, minutes, or hours.
boards.selector.columnNameStatusName of selector field to group tasks (i.e. not started, in progress, complete, etc.)
boards.selector.sourceColumnCompletedName of column from which to move tasks.
boards.selector.targetColumnArchivedName of column to move tasks to.

# Functions

FilterOnLastEditedTime filters a list of tasks to find tasks that occured before some cutoff time.
FindRefreshInterval finds the greatest common divisor of all ArchiveAfter fields in a slice of TaskBoards.
LoadConfigurationFile takes the path to a configuration file, parses it, and sets default values.
NewNotionHandler creates a new NotionHandler struct with an initialized handler.

# Structs

Configuration is a struct represenation of the program configuration file.
NotionHandler is container that holds a notion client and other associated information.
TaskBoard contains all settings for a single task board in Notion.