Skip to content

Kenya-West/gh-actions-env-create

Repository files navigation


Logo

GitHub Actions environment create

Create GitHub Actions secrets needed for any of your repository to be build and deployed

Report Bug · Request Feature

Contributors Forks Stargazers Issues MIT License LinkedIn

JavaScript DotEnv

Telegram License

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

The reason this repository exist is that I had to repeatedly create typical secrets with the same keys again and again, and decided to automate it with Node.

(back to top)

Built With

Node

(back to top)

Getting Started: usage

Prerequisites

  • Ensure git and node are installed;
  • You need to have an own GitHub PAT with write access for GitHub Actions secrets.

Is recommended:

  • To have specific SSH key for GitHub Actions.

Installation

  1. First, you need to clone this repo using Git:
    git clone https://github.com/Kenya-West/xui-api-server.git
  2. Install NPM packages:
    npm ci
  3. Duplicate directory ./projects/some-proj/ at the same level with desired project name and write down the following values in .env files:
    • .env.github-actions-setup: data required for script to run;
    • .env.github-actions-secrets: list of secrets to be set in GitHub Actions secrets for the project;
    • .env contents. They may (or may not) be used to create .env file in destination machine, decoded from base64.
  4. After setuping project and filling needed values, you can launch the script with the following command:
    node ./index.js --project=YOUR_PROJECT_NAME
    The output would be like so:
    node ./index.js --project=sd-article-summarizer-bot
    Project path: sd-article-summarizer-bot
    Successfully set secret: VPS_USERNAME
    Successfully set secret: VPS_IP
    Successfully set secret: SSH_PRIVATEKEY
    Successfully set secret: PROJECT_DOCKERCONTAINERNAME
    Successfully set secret: PROJECT_DIRNAME
    Successfully set secret: DOCKERHUB_USERNAME
    Successfully set secret: DOCKERHUB_TOKEN
    Successfully set secret: DOCKERHUB_REPONAME
    Successfully set secret: ENV_CONTENT

Usage in CI/CD

After variables and secret have been populated in GitHub repo, you can use them in your CI/CD pipeline. An example is set in .github-example/workflows/ci.yml.

Advanced usage with custom file creation

You can also create custom files in the destination machine:

  1. Create a file named .env.PROJECTFILES_<ANY NAME>, e. g. .env.PROJECTFILES_PADSJSON or just .env.PROJECTFILES_PADS;

  2. Inside the file, set necessary content that you want to be created in the destination machine;

  3. To create the file in the target machine, use the following line in ci.yml file:

    - name: Create custom file
      run: echo "${{ secrets.PROJECTFILES_PADS }}" | base64 --decode > ./pads.json

    This will create a file named pads.json in the root of the project directory, containing the content from .env.PROJECTFILES_PADS.

Full example is available in .github-example/workflows/ci-custom-files.yml.

(back to top)

Getting Started: contributing & development

Prerequisites

  • Ensure git and node are installed;
  • You need to have an own GitHub PAT with write access for GitHub Actions secrets.

Is recommended:

  • To have specific SSH key for GitHub Actions.

Installation

Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.

First, you need to clone this repo using Git:

  1. git:
    git clone https://github.com/Kenya-West/xui-api-server.git
  2. Install NPM packages:
    npm ci
  3. Enjoy exploring things!

(back to top)

Roadmap

  • Rest this weekend well

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Top contributors:

contrib.rocks image

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - @Kenya-West - [email protected]

Project Link: https://github.com/Kenya-West/gh-actions-env-create

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

About

Bulk create/update GitHub Actions secrets per-repo

Topics

Resources

License

Stars

Watchers

Forks