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.
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.
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
Run prepare
npm run prepare
2. Create YML file in .github/workflows/main.yml and change to your JavaScript Action repository url
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) }}