GithubHelp home page GithubHelp logo

james-rms / replace_envs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from franzbischoff/replace_envs

0.0 0.0 0.0 496 KB

This action has the simple task of replacing the placeholders of Environment Variables with their values.

License: MIT License

JavaScript 100.00%

replace_envs's Introduction

Gitpod ready-to-code

Licensed Build tests License Language grade: JavaScript

Replace Environment Variables Action

This action has the simple task of replacing the placeholders of Environment Variables with their values.

For example, you have a README.md file in a template repository, and you want to have a link that points to your new repository just after you 'fork' it.

So in your template repository, you may have a line like this:

https://github.com/${GITHUB_REPOSITORY}/

And this will be translated (as in this repository) as:

https://github.com/franzbischoff/replace_envs/

In this link is the default list of environment variables that Github has set.

In addition, you may set your own variables in the workflow YAML file like this:

    env:
      MY_CUSTOM_VARIABLE: 'some value'

That's all it does.

Lastly, just three comments:

  • I've created two new variables called REPOSITORY_ACCOUNT and REPOSITORY_ACCOUNT that is derived from the GITHUB_REPOSITORY variable, to make it easier to use in some use-cases.
  • The changes are by default pushed to the repository. If this action is part of a chain of steps, and you want to push the changes later, by yourself, you can disable this behavior with the parameter commit: 'false'.
  • The input and output file can be either a template -> definitive or definitive -> definitive; this just means that the input and output may be the same file. The later attempts to replace, by this action, will 'fail' safely without an Error code.

Why use this action?

I know there are other actions that accomplish the same objective, but:

  • This is self-contained (only needs to be preceded by actions/checkout)
  • It is plain JavaScript, few lines of code, easy to inspect and see that this action only does what it does.

Usage

Create a YAML file at .github/workflows/myworkflow.yml

GITHUB_TOKEN must be set, otherwise this action cannot perform changes in your repository.

steps:
  - uses: actions/checkout@v2
  - uses: franzbischoff/replace_envs@v1
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      MY_CUSTOM_VARIABLE: 'some value'
    with:
      from_file: 'README.md'
      to_file: 'README.md'
      commit: 'true'

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

The scripts and documentation in this project are released under the MIT License

Contributions

Contributions are welcome! See Contributor's Guide

Code of Conduct

๐Ÿ‘‹ Be nice. See the code of conduct

replace_envs's People

Contributors

bryanmacfarlane avatar dependabot-preview[bot] avatar dependabot[bot] avatar franzbischoff avatar fregante avatar github-actions[bot] avatar hross avatar james-rms avatar jasonetco avatar mend-bolt-for-github[bot] avatar ph1p avatar rchougule avatar thboop avatar theworkfsz avatar vitornovictor avatar wesleytodd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.