Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gayanvoice/javascript-action

JavaScript Action makes it easy to commit all your changes to repository with CI/CD.
https://github.com/gayanvoice/javascript-action

fs-extra github-actions javascript javascript-action simple-git

Last synced: about 1 month ago
JSON representation

JavaScript Action makes it easy to commit all your changes to repository with CI/CD.

Awesome Lists containing this project

README

        

# JavaScript Action | File Handling and GitHub Operations

Use this repository to bootstrap the creation of a JavaScript action for file handling and Git operations.

This repository includes create directory, create Json file, read Json file, git commit and git push.

## Create an action from this repository

### 1. Folk the repository

### 2. Change the git.js

Go to src/git/git.js and
change
user.email
with your GitHub account's primary email
and
user.name
with your GitHub profile name.

```javascript
const {exec} = require('child_process');
const core = require('@actions/core');

async function commit() {
core.info('git commit');
exec('git config --global user.email "[email protected]"');
exec('git config --global user.name "GitHub Name"');
exec('git add .');
exec('git commit -m "message"');
}

module.exports = commit
```

### 3. Package for distribution

Run prepare

```bash
npm run prepare
```

### 4. Push changes to repository

## Create a workflow

### 1. Create an empty repository or go to an existing repository

### 2. Create YML file in .github/workflows/main.yml and change to your JavaScript Action repository url

```yml
name: JavaScript CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
deployment:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: JavaScript Action
uses: gayanvoice/javascript-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
```
### 3. Go to Actions to see the process