Skip to content

Commit 0e10993

Browse files
author
Securelay Bot
committed
Commit by @github-actions for Expire
0 parents  commit 0e10993

13 files changed

Lines changed: 547 additions & 0 deletions

File tree

.expiry/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# .expiry
2+
This directory contains expiry data for the JSONs in [../silo](../silo/).

.github/workflows/expire.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Brief: Expire JSON files from /silo based on their expiry in /.expiry
2+
# Note: Must be run on default branch
3+
4+
name: Expire
5+
6+
on:
7+
workflow_dispatch: # Enables manual triggering
8+
schedule: # Enables scheduled triggerring
9+
- cron: '30 1 * * *' # Trigger at around 1:30 AM every day
10+
11+
concurrency:
12+
group: ${{ github.repository }}
13+
cancel-in-progress: false
14+
15+
jobs:
16+
17+
expire:
18+
19+
permissions:
20+
contents: write
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: '20.x'
29+
check-latest: false
30+
- name: Expire # Should not fail even if there is nothing to expire or delete
31+
run: npm run expire
32+
- name: Push to GitHub # Should not fail even if there is nothing to commit
33+
run: |
34+
git config --global user.name 'Securelay Bot'
35+
git config --global user.email 'securelay.github.io@gmail.com'
36+
git add .
37+
git diff-index --quiet HEAD || \
38+
{ git commit --amend --reset-author -m 'Commit by @github-actions for Expire' && git push -f; }

.github/workflows/pull.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Brief: This workflow pulls data from upstream database and stores in this repo
2+
# Note: Must be run on default branch
3+
4+
name: Pull
5+
6+
on:
7+
workflow_dispatch: # Enables manual triggering
8+
schedule: # Enables scheduled triggerring. Max frequency allowed by GitHub is, trigger every 5 mins
9+
- cron: '5/10 * * * *' # Trigger every 10 mins starting from 5th min of every hour
10+
# Not starting at the start of every hour, as recommended by GitHub, to avoid delay
11+
# Ref: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
12+
13+
concurrency:
14+
group: ${{ github.repository }}
15+
cancel-in-progress: false
16+
17+
jobs:
18+
19+
pull:
20+
21+
permissions:
22+
contents: write
23+
issues: write
24+
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: '20.x'
32+
check-latest: false
33+
cache: 'npm'
34+
- run: npm ci # Clean, frozen install. Doesn't modify package.json or package-lock.json
35+
- name: Pull and add to filesystem # Should not fail even if there is nothing to add
36+
env:
37+
GITHUB_OWNER_REPO: ${{ github.repository }}
38+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
39+
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
40+
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
41+
run: npm run pull
42+
- name: Push to GitHub # Should not fail even if there is nothing to commit
43+
run: |
44+
git config --global user.name 'Securelay Bot'
45+
git config --global user.email 'securelay.github.io@gmail.com'
46+
git add .
47+
git diff-index --quiet HEAD || \
48+
{ git commit --amend --reset-author -m 'Commit by @github-actions for Pull' && git push -f; }

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules

LICENSE

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Creative Commons Legal Code
2+
3+
CC0 1.0 Universal
4+
5+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12+
HEREUNDER.
13+
14+
Statement of Purpose
15+
16+
The laws of most jurisdictions throughout the world automatically confer
17+
exclusive Copyright and Related Rights (defined below) upon the creator
18+
and subsequent owner(s) (each and all, an "owner") of an original work of
19+
authorship and/or a database (each, a "Work").
20+
21+
Certain owners wish to permanently relinquish those rights to a Work for
22+
the purpose of contributing to a commons of creative, cultural and
23+
scientific works ("Commons") that the public can reliably and without fear
24+
of later claims of infringement build upon, modify, incorporate in other
25+
works, reuse and redistribute as freely as possible in any form whatsoever
26+
and for any purposes, including without limitation commercial purposes.
27+
These owners may contribute to the Commons to promote the ideal of a free
28+
culture and the further production of creative, cultural and scientific
29+
works, or to gain reputation or greater distribution for their Work in
30+
part through the use and efforts of others.
31+
32+
For these and/or other purposes and motivations, and without any
33+
expectation of additional consideration or compensation, the person
34+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35+
is an owner of Copyright and Related Rights in the Work, voluntarily
36+
elects to apply CC0 to the Work and publicly distribute the Work under its
37+
terms, with knowledge of his or her Copyright and Related Rights in the
38+
Work and the meaning and intended legal effect of CC0 on those rights.
39+
40+
1. Copyright and Related Rights. A Work made available under CC0 may be
41+
protected by copyright and related or neighboring rights ("Copyright and
42+
Related Rights"). Copyright and Related Rights include, but are not
43+
limited to, the following:
44+
45+
i. the right to reproduce, adapt, distribute, perform, display,
46+
communicate, and translate a Work;
47+
ii. moral rights retained by the original author(s) and/or performer(s);
48+
iii. publicity and privacy rights pertaining to a person's image or
49+
likeness depicted in a Work;
50+
iv. rights protecting against unfair competition in regards to a Work,
51+
subject to the limitations in paragraph 4(a), below;
52+
v. rights protecting the extraction, dissemination, use and reuse of data
53+
in a Work;
54+
vi. database rights (such as those arising under Directive 96/9/EC of the
55+
European Parliament and of the Council of 11 March 1996 on the legal
56+
protection of databases, and under any national implementation
57+
thereof, including any amended or successor version of such
58+
directive); and
59+
vii. other similar, equivalent or corresponding rights throughout the
60+
world based on applicable law or treaty, and any national
61+
implementations thereof.
62+
63+
2. Waiver. To the greatest extent permitted by, but not in contravention
64+
of, applicable law, Affirmer hereby overtly, fully, permanently,
65+
irrevocably and unconditionally waives, abandons, and surrenders all of
66+
Affirmer's Copyright and Related Rights and associated claims and causes
67+
of action, whether now known or unknown (including existing as well as
68+
future claims and causes of action), in the Work (i) in all territories
69+
worldwide, (ii) for the maximum duration provided by applicable law or
70+
treaty (including future time extensions), (iii) in any current or future
71+
medium and for any number of copies, and (iv) for any purpose whatsoever,
72+
including without limitation commercial, advertising or promotional
73+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74+
member of the public at large and to the detriment of Affirmer's heirs and
75+
successors, fully intending that such Waiver shall not be subject to
76+
revocation, rescission, cancellation, termination, or any other legal or
77+
equitable action to disrupt the quiet enjoyment of the Work by the public
78+
as contemplated by Affirmer's express Statement of Purpose.
79+
80+
3. Public License Fallback. Should any part of the Waiver for any reason
81+
be judged legally invalid or ineffective under applicable law, then the
82+
Waiver shall be preserved to the maximum extent permitted taking into
83+
account Affirmer's express Statement of Purpose. In addition, to the
84+
extent the Waiver is so judged Affirmer hereby grants to each affected
85+
person a royalty-free, non transferable, non sublicensable, non exclusive,
86+
irrevocable and unconditional license to exercise Affirmer's Copyright and
87+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
88+
maximum duration provided by applicable law or treaty (including future
89+
time extensions), (iii) in any current or future medium and for any number
90+
of copies, and (iv) for any purpose whatsoever, including without
91+
limitation commercial, advertising or promotional purposes (the
92+
"License"). The License shall be deemed effective as of the date CC0 was
93+
applied by Affirmer to the Work. Should any part of the License for any
94+
reason be judged legally invalid or ineffective under applicable law, such
95+
partial invalidity or ineffectiveness shall not invalidate the remainder
96+
of the License, and in such case Affirmer hereby affirms that he or she
97+
will not (i) exercise any of his or her remaining Copyright and Related
98+
Rights in the Work or (ii) assert any associated claims and causes of
99+
action with respect to the Work, in either case contrary to Affirmer's
100+
express Statement of Purpose.
101+
102+
4. Limitations and Disclaimers.
103+
104+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
105+
surrendered, licensed or otherwise affected by this document.
106+
b. Affirmer offers the Work as-is and makes no representations or
107+
warranties of any kind concerning the Work, express, implied,
108+
statutory or otherwise, including without limitation warranties of
109+
title, merchantability, fitness for a particular purpose, non
110+
infringement, or the absence of latent or other defects, accuracy, or
111+
the present or absence of errors, whether or not discoverable, all to
112+
the greatest extent permissible under applicable law.
113+
c. Affirmer disclaims responsibility for clearing rights of other persons
114+
that may apply to the Work or any use thereof, including without
115+
limitation any person's Copyright and Related Rights in the Work.
116+
Further, Affirmer disclaims responsibility for obtaining any necessary
117+
consents, permissions or other rights required for any use of the
118+
Work.
119+
d. Affirmer understands and acknowledges that Creative Commons is not a
120+
party to this document and has no duty or obligation with respect to
121+
this CC0 or use of the Work.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[![Pull](https://github.com/securelay/jsonbin/actions/workflows/pull.yml/badge.svg)](https://github.com/securelay/jsonbin/actions/workflows/pull.yml) [![Expire](https://github.com/securelay/jsonbin/actions/workflows/expire.yml/badge.svg)](https://github.com/securelay/jsonbin/actions/workflows/expire.yml)
2+
3+
# jsonbin
4+
Persistent JSON store for [Securelay](https://github.com/securelay/specs).
5+
6+
## Directory structure
7+
- JSON files are found in [silo](./silo/).
8+
9+
- The unix-time, in seconds, that `silo/{UUID}.json` expires at, is stored in [.expiry](./.expiry) as `.expiry/{UUID}.expiry`.
10+
11+
12+
## Public access, CDN
13+
The stored JSONs may be accessed publicly:
14+
- by using a CDN, e.g. [JSDelivr](https://www.jsdelivr.com/?docs=gh) or [Statically](https://statically.io/). These respond with `Content-Type: application/json` header, as desired.
15+
16+
- by using *raw.githubusercontent.com* with the schema: `https://raw.githubusercontent.com/securelay/jsonbin/main/silo/{UUID}.json`. This responds with `content-type: text/plain; charset=utf-8`.
17+
18+
Both these options however, may cache the JSON for a while, because of which, any changes brought about by a commit (such as creating/updating/deleting a JSON) may not be reflected immediately.
19+
20+
## Workflows
21+
The following workflows keep this repo up-to-date. All workflows share the same concurrency key, so that only one workflow runs at any given time. All workflows are triggerred only if they belong to the default branch.
22+
23+
### Pull
24+
New JSONs are pulled from upstream by the workflow, [pull.yml](./.github/workflows/pull.yml). This workflow is triggered on demand by the `workflow_dispatch` event. It also runs regularly as a scheduled cronjob.
25+
26+
Integration with Securelay is as follows.
27+
- As new JSONs are created, Securelay enqueues them in an upstream database.
28+
- After the first enqueue event every cycle, i.e. after pushing the first JSON in an otherwise empty queue, Securelay adds the label `pull` to issue [#1](https://github.com/securelay/jsonbin/issues/1). Along with this, it also triggers a `workflow_dispatch` event in this repository to run the workflow on-demand.
29+
- The workflow first tries to remove the said issue-label. If the label didn't exist, it is inferred that the upstream is empty and the workflow then exits gracefully.
30+
- If issue-label is removed successfully, the workflow pulls JSONs from upstream in batches until empty.
31+
32+
### Expire
33+
Expired JSONs are removed by the workflow, [expiry.yml](./.github/workflows/expiry.yml). This workflow is triggerred regularly as a cronjob.
34+
35+
## Fair use policy
36+
Not to abuse GitHub,
37+
- activities (such as pushes and workflow runs) on this repository are kept sparse.
38+
- only very small JSONs (<=10 KB each) are allowed to be pushed. Repository size is kept within a few GBs by regularly pruning the expired JSONs.
39+
40+
If you use this repository directly or indirectly, you are bound by and agree to
41+
- [GitHub Terms of Service](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service)
42+
- [Securelay Terms of Service](https://securelay.github.io/ToS.txt)
43+
- [License](./LICENSE) and the following [Data policy](#data-policy)
44+
45+
## Data policy
46+
Any given JSON file within [silo/](./silo/), is created by a [Securelay](https://securelay.github.io) user with a private key, in order to be disseminated publicly. If you are such a user, you understand that data in your JSON file is/will be in the public domain once it appears in this repository. Although JSONs can be deleted from this repository by the creator through Securelay, the data may persist on GitHub and different CDN servers that may have cached the data.
47+
48+
## Contact
49+
Email: [securelay.github.io@gmail.com](mailto:securelay.github.io@gmail.com)
50+
51+
## Note to maintainer
52+
- `cd` to local clone of this repository
53+
- `git switch dev`
54+
- Modify code or documentation in the `dev` branch
55+
- Commit and push to the `dev` branch
56+
- Run:
57+
```bash
58+
./push_dev_to_main_as_only_commit
59+
```
60+
This ensures stored JSONs are not lost from `main`.
61+
62+
:warning: DONOT modify the contents of the `main` branch manually, as it may result in data loss. Use [push_dev_to_main_as_only_commit](./push_dev_to_main_as_only_commit) for pushing necessary code/documentation changes to `main` from `dev`.

0 commit comments

Comments
 (0)