You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Get persistent value
v1.1.0
- Set a persistent value: aaimio/set-persistent-value
- Get a persistent value: aaimio/get-persistent-value
Set or get a value that persists through GitHub Actions jobs, steps, or workflows.
Example use cases:
- 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 optional
Any questions, comments, feedback? Join the #gh-persistent-values channel on my Slack.
Generate an access token by visiting the URL below:
The set-persistent-value action takes the inputs below:
Input | Description |
---|---|
key |
An identifier with which you can retrieve the stored value. |
value |
The value to store |
access_token |
Use curl to generate one (or simply visit the URL directly), after generating, add the access token as a GitHub secret for your repo (e.g. PERSISTENT_VALUE_ACCESS_TOKEN ). You can generate a token using curl https://persistent.aaim.io/api/values/new_access_token?output=plain . |
steps:
- name: Set a persistent value
id: set_persistent_value
uses: aaimio/set-persistent-value@v1
with:
key: foo
value: bar
access_token: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}
The get-persistent-value action takes the inputs below:
Input | Description |
---|---|
key |
An identifier with which you can retrieve the stored value. |
access_token |
Use curl to generate one (or simply visit the URL directly), after generating, add the access token as a GitHub secret for your repo (e.g. PERSISTENT_VALUE_ACCESS_TOKEN ). You can generate a token using curl https://persistent.aaim.io/api/values/new_access_token?output=plain . |
steps:
- name: Get a persistent value
id: get_persistent_value
uses: aaimio/get-persistent-value@v1
with:
key: foo
access_token: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}
- name: Some other step
run: |
echo ${{ steps.get_persistent_value.outputs.value }}
In the background, the action is interfacing with a simple key-value store built specifically for this use case.
To reduce the overhead of downloading the action(s) or introducing yet another step into your workflow, you're more than welcome to use the API directly:
curl -X POST \
-H 'x-api-key: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}' \
-H 'x-github-repo: <GITHUB_OWNER/GITHUB_REPO>' \
-H 'content-type: application/json' \
-d '{ "value": "some_value" }' \
'https://persistent.aaim.io/api/values/set?key=YOUR_KEY&output=plain'
SOME_VALUE=$(curl -X GET \
-H 'x-api-key: ${{ secrets.PERSISTENT_VALUE_ACCESS_TOKEN }}' \
-H 'x-github-repo: <GITHUB_OWNER/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.
- Items will persist until the
access_token
hasn't been used for 3 months.