CI/CD & Service Tokens
In pipelines and servers there is no one to type a password, so use a service token: a credential that can only access the secrets of one environment of one project. When the STASH_TOKEN environment variable is set, stash run, stash pull and stash secrets use it automatically, with no login and no --project/--env flags.
1. Create a token
In the web app open the project, go to Service tokens → New token, or from the CLI:
stash tokens create github-actions --env prod --access read --expires-in-days 90
- The token (
stash_st_…) is shown only once. Store it in your CI's secret settings. - Use
readunless the pipeline needs to change secrets. - The token acts with the permissions of the person who created it, and stops working if that person leaves the organization. Revoke it any time from the same tab or with
stash tokens revoke.
2. GitHub Actions
Save the token as a repository secret named STASH_TOKEN (Settings → Secrets and variables → Actions), then:
jobs:
deploy:
runs-on: ubuntu-latest
env:
STASH_TOKEN: ${{ secrets.STASH_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install Stash CLI
run: |
curl -fsSL https://github.com/bushcoding/stash/releases/latest/download/install.sh | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- run: stash run -- npm run deployIf a tool needs a file instead of environment variables, write one with stash pull --file .env --force. Prefer having Stash push the secrets straight into GitHub? See Integrations.
3. Servers and Docker
Any machine with the CLI installed can start your app with the token:
export STASH_TOKEN=stash_st_... stash run -- node server.js
Pass the token to the container at runtime (for example docker run -e STASH_TOKEN …), never bake it into the image.