From 50bc51ab59d43a36c50299dc4c49fa4cf9b54360 Mon Sep 17 00:00:00 2001 From: Noam Liran Date: Fri, 9 Oct 2020 21:42:24 +0300 Subject: [PATCH] Updated README.md --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b332ca7..c5dcc89 100644 --- a/README.md +++ b/README.md @@ -1 +1,28 @@ -# branch-based-secrets +# `branch-based-secrets` GitHub Action + +This action makes it easy to use different secrets for different branches. +It relies on the following naming scheme for secrets: `_`. + +## Usage example + +In a project with 2 branches, `prod` and `dev`, define the following secrets: +* `SECRET_TOKEN_DEV` +* `SECRET_TOKEN_PROD` + +Step configuration: +```yaml + - uses: noliran/branch-based-secrets@v1 + with: + secrets: SECRET_TOKEN +``` + +In turn, when running an action on a push to `dev` or a pull_request targeted at branch `dev`, this will define the following environment variables: +* `SECRET_TOKEN_NAME`=`SECRET_TOKEN_DEV` +* `TARGET_BRANCH`=`dev` +* `TARGET_BRANCH_U`=`DEV` + +After the action runs, you can pass the correct secret to other steps: +```yaml + env: + SECRET_TOKEN: ${{ secrets[env.SECRET_TOKEN_NAME] }} +``` \ No newline at end of file