Skip to content

Initialize Repository file structure for Node.js Express and MySQL

License

Notifications You must be signed in to change notification settings

Sunwoo0110/IREM

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

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IREM : Initialize Repository file structure for Node.js Express and MySQL

This action provides the following functionality for GitHub Actions users:

  • Initializing your repository file structure for Node.js Express and MySQL
  • Automatically detecting .env file and setting it accordingly (Not implemented yet)

Basic usage

see action.yml and .github/workflows/test_clone_dispatch.yaml.

steps:
  - name: Checkout
    uses: actions/checkout@v3
  - name: Setup Repository
    uses: actions/IREM@v1
    with:
      github-repo-url: ${{ inputs.github-repo-url }}
      github-user-id: ${{ inputs.github-user-id }}
      github-user-email: ${{ inputs.github-user-email }}
      github-token: ${{ secrets.GH_TOKEN }}

Inputs (* : required)

github-repo-url*

Your github repository url where you want to initialize

github-user-id*

Your github ID

github-user-email*

Your github Email

github-token*

Your github Personal Access Token (PAT)

Please add PAT to GitHub Secrets in the repo

Example

name: Setup Nodejs Express && MySQL Directory Structure

on:
  workflow_dispatch:
    inputs:
      github-repo-url:
        description: "GitHub Repository URL which you want to Setup"
        required: true
        default: ''
      github-user-id: 
        description: "GitHub User ID"
        required: true
        default: ''
      github-user-email:
        description: "GitHub User Email"
        required: true
        default: ''

jobs:
   git_clone_test:
    runs-on: ubuntu-latest
    name: Git clone test
    steps:
      - run: ls
      - name: Setup Repository
        uses: Sunwoo0110/[email protected]
        with:
          github-repo-url: ${{ inputs.github-repo-url }}
          github-user-id: ${{ inputs.github-user-id }}
          github-user-email: ${{ inputs.github-user-email }}
          github-token: ${{ secrets.GH_TOKEN }}

Usage Scenario

1. Make repository on your github

image

2. Write and add a workflow file to ./github/workflows/ . See Example.

image image image

3. Add your PAT to GitHub.Secrets (variable name : GH_TOKEN)

image image image image image image image

4. Trigger the action according to the format you created.

In this example, we use [workflow_dispatch] trigger. image image image

5. Check if it works well on the action tap and your repository.

image image image

After action executed

  1. Clone your repository and pull to local directory
  2. Create your env file about mysql. See env.sample file.
  3. Type npm install, then node_nodules and package-lock.json will created.
  4. If you want to start server, type npm start.
  5. To make api, add file to src/routes and router to src/index.js. See test code.

Expected Completed File Structure After Action

* πŸ“¦ [Your Repo]
  β”œβ”€β”€ ξ˜‹ package.json
  β”œβ”€β”€ ξ˜‹ .env.sample
  β”œβ”€β”€ ο„• src
  β”‚   β”œβ”€β”€ ο„• config
  β”‚   β”‚   └──  config.js
  β”‚   β”œβ”€β”€ ο„• routes
  β”‚   β”‚   β”œβ”€β”€ ο„• test
  β”‚   β”‚   β”‚   β”œβ”€β”€  test.ctrl.js
  β”‚   β”‚   β”‚   └── ο„• index.js
  β”‚   β”‚   β”œβ”€β”€  db.js
  β”‚   β”‚   └──  index.js
  β”‚   β”œβ”€β”€  app.js
  β”‚   └──  server.js
  └──  .gitignore

Default Dependencies

body-parser: v1.20.0
dotenv: v16.0.1
express: v4.18.1
mysql2: v2.3.3
nodemon: v2.0.18

File Structure

* πŸ“¦ IREM
  β”œβ”€β”€ ο„• .github
  β”‚   β”œβ”€β”€ ο„• workflows
  β”‚   β”‚   └──  test_clone_dispatch.yml
  β”œβ”€β”€ ο„• src
  β”‚   β”œβ”€β”€ ο„• make_appserver.sh
  β”‚   β”œβ”€β”€ ο„• make_config.sh
  β”‚   β”œβ”€β”€ ο„• make_env_sample.sh
  β”‚   β”œβ”€β”€ ο„• make_gitignore.sh
  β”‚   β”œβ”€β”€ ο„• make_package_dot_json.sh
  β”‚   β”œβ”€β”€ ο„• make_routes.sh
  β”‚   └──  make_src_directory.sh
  β”œβ”€β”€ ξ˜‹ Dockerfile
  β”œβ”€β”€ ξ˜‹ action.yml
  └──  main.sh

License

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

Contributors

About

Initialize Repository file structure for Node.js Express and MySQL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published