Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaimio/get-persistent-value
Gets a value that persists through GitHub Action jobs, steps, or workflows.
https://github.com/aaimio/get-persistent-value
actions github-actions variables
Last synced: about 2 months ago
JSON representation
Gets a value that persists through GitHub Action jobs, steps, or workflows.
- Host: GitHub
- URL: https://github.com/aaimio/get-persistent-value
- Owner: aaimio
- License: mit
- Created: 2021-04-18T11:17:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T17:21:04.000Z (over 1 year ago)
- Last Synced: 2024-10-31T10:43:00.747Z (2 months ago)
- Topics: actions, github-actions, variables
- Language: TypeScript
- Homepage: https://github.com/marketplace/actions/get-persistent-value
- Size: 312 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![uptime](https://badgen.net/uptime-robot/status/m787894343-bf1ddacfde07d95ec87e488c)
![uptime](https://badgen.net/uptime-robot/day/m787894343-bf1ddacfde07d95ec87e488c)
![uptime](https://badgen.net/uptime-robot/week/m787894343-bf1ddacfde07d95ec87e488c)
![uptime](https://badgen.net/uptime-robot/month/m787894343-bf1ddacfde07d95ec87e488c)- [Usage](#usage)
- [Set a persistent value](#set-a-persistent-value)
- [Get a persistent value](#get-a-persistent-value)
- [Using the API directly](#using-the-api-directly)
- [Setting a value](#setting-a-value)
- [Getting a value](#getting-a-value)
- [Things to note](#things-to-note)# Overview
**Set or get a value that persists through GitHub Actions jobs, steps, or workflows.**
- Execute some logic if a file hash has changed
- Keep track of a URL required in other steps of your workflow (like a Vercel preview URL)
- Set a boolean value to make other steps in your workflow optionalAny questions, comments, feedback? [Join the #gh-persistent-values channel](https://join.slack.com/t/aaimio/shared_invite/zt-ufy5w5rl-_xPGk4Tew4HyHSiYhsD33w) or [open a new issue](https://github.com/aaimio/set-persistent-value/issues/new).
- [set-persistent-value](https://github.com/aaimio/set-persistent-value)
- [get-persistent-value](https://github.com/aaimio/get-persistent-value)## Usage
### [Set a persistent value](https://github.com/aaimio/set-persistent-value)
**Set a single value**
For single values, the action takes the inputs below:
| Input | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `key` | The key for the value you want to set |
| `value` | The value to set |
| `access_token` | [Visit this URL](https://persistent.aaim.io/api/values/new_access_token?output=plain), then add this access token as a GitHub secret to your repo (e.g. `PERSISTENT_VALUE_ACCESS_TOKEN`). |```yaml
steps:
- name: Set a persistent value
id: set_persistent_value
uses: aaimio/[email protected]
with:
key: foo
value: bar
access_token: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}
```**Set multiple values**
For multiple values, the action takes the inputs below:
| Input | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `json` | A JSON string with the keys and values you want to set |
| `access_token` | [Visit this URL](https://persistent.aaim.io/api/values/new_access_token?output=plain), then add this access token as a GitHub secret to your repo (e.g. `PERSISTENT_VALUE_ACCESS_TOKEN`). |```yaml
steps:
- name: Set a persistent value
id: set_persistent_value
uses: aaimio/[email protected]
with:
json: '{ "some_key": 42, "foo": "bar", "boolean_value": true }'
access_token: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}
```### [Get a persistent value](https://github.com/aaimio/get-persistent-value)
This action takes the inputs below:
| Input | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `key` | The key for the value you want to retrieve |
| `access_token` | [Visit this URL](https://persistent.aaim.io/api/values/new_access_token?output=plain), then add this access token as a GitHub secret to your repo (e.g. `PERSISTENT_VALUE_ACCESS_TOKEN`). |```yaml
steps:
- name: Get a persistent value
id: get_persistent_value
uses: aaimio/[email protected]
with:
key: foo
access_token: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}
- name: Some other step
run: |
echo ${{ steps.get_persistent_value.outputs.value }}
```### Using the API directly
In the background, the action is talking to a simple key-value store.
To reduce the overhead of downloading the action or introducing yet another step into your workflow, you could also use the API directly:
#### Setting a value
```bash
curl -X POST \
-H 'x-api-key: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}' \
-H 'x-github-repo: ' \
-H 'content-type: application/json' \
-d '{ "value": "some_value" }' \
'https://persistent.aaim.io/api/values/set?key=YOUR_KEY&output=plain'
```#### Getting a value
```bash
SOME_VALUE=$(curl -X GET \
-H 'x-api-key: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}' \
-H 'x-github-repo: ' \
'https://persistent.aaim.io/api/values/get?key=YOUR_KEY&output=plain')echo $SOME_VALUE
```- The `x-github-repo` header is completely optional, it will only keep track of which repositories are using the action or API.
### Things to note
- Items will persist until the `access_token` hasn't been used for 3 months.