Skip to content

Latest commit

 

History

History
147 lines (101 loc) · 3.23 KB

README.md

File metadata and controls

147 lines (101 loc) · 3.23 KB

Env Action

Github Action to create .env using secrets.

📋 Table of contents

📦 Installation

Install the dependencies

yarn install

Run the tests ✔️

$ yarn test

 PASS  ./index.test.js
  ✓ test runs (95ms)
...

🔁 Change the Action

The action.yml defines the inputs and output for your action.

Update the action.yml and index.js if you want to make changes to the action.

⌨️ Change the Code

Most toolkit and CI/CD operations involve async operations so the action is run in an async function.

const core = require('@actions/core');
...

async function run() {
  try {
      ...
  }
  catch (error) {
    core.setFailed(error.message);
  }
}

run()

🚀 Usage

You can now consume the action by referencing the release branch, e.g.: @v1

uses: eteg/zcli-action@v1

This is a complete example of the action usage for development purposes.:

name: zcli-action-dev

on:
  push:
    branches: ["develop"]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    env:
      ZENDESK_SUBDOMAIN: ${{ secrets.ZENDESK_SUBDOMAIN_DEV }}
      ZENDESK_EMAIL: ${{ secrets.ZENDESK_EMAIL_DEV }}
      ZENDESK_API_TOKEN: ${{ secrets.ZENDESK_API_TOKEN_DEV }}

    steps:
      - name: Setup Checkout
        uses: actions/checkout@v3

      - name: Setup Node ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: npm
          cache-dependency-path: "./yarn.lock"

      - name: Setup ZCLI
        uses: eteg/zcli-action@v1
        with:
          env: "dev"

NOTE: You must setup env variables in Github Action Secrets

NOTE: Don't forget to add env in Setup ZCLI, the env must be exactly dev or prod.

✉️ Package for distribution

GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.

Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.

Run prepare for distribution

yarn run prepare

Since the packaged index.js is run from the dist folder.

git add dist

🤯 Create a release branch

Users shouldn't consume the action from master since that would be latest code and actions can break compatibility between major versions.

Checkin to the v1 release branch

git checkout -b v1
git commit -a -m "v1 release"
git push origin v1

Your action is now published! 🚀

📜 License

This project have no license. You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work. Github licensing page.