Skip to content

BlobDevelopment/copy-and-replace-tokens

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

copy-and-replace-tokens

This action will copy a file and replace tokens (env variables surrounded by {}, eg {USER} is a token for the env variable USER).

Inputs

There's two inputs available for this action.

  • source - Defines the source file to copy and replace tokens in.
  • target - Defines the output target file.

Example

Example action:

- name: Setting up config file
  uses: BlobDevelopment/copy-and-replace-tokens@v1
  with:
    source: 'config.yml.template'
    target: 'config.yml'
  env:
    MYSQL_HOST: mysql
    MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}
    MYSQL_USER: ${{ secrets.MYSQL_USER }}
    MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}

Example config.yml: Add to a workflow if you wish to copy a file and replace tokens inside of it.

Example usage:

- name: Setting up config
  uses: BlobDevelopment/copy-and-replace-tokens@v1
  with:
    source: 'config.yml.template'
    target: 'config.yml'
  env:
    MYSQL_HOST: mysql
    MYSQL_USER: ${{ secrets.MYSQL_USER }}
    MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
    MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }}

Example config.yml file:

mysql:
  host: {MYSQL_HOST}
  port: 3306
  username: {MYSQL_USER}
  password: {MYSQL_PASSWORD}
  database: {MYSQL_DATABASE}