-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,048 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# action-autocommit | ||
Commit changes made to a repo within a CI (example: run a script, then commit and push) | ||
|
||
This action will commit and push all changes made to the current repo. | ||
With this action you can make changes within a CI and automatically push it to the current branch. | ||
|
||
Example of usage: | ||
|
||
```yaml | ||
name: Docgen | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
docgen: | ||
name: Docgen | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@master | ||
|
||
- name: Install Node v12 | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 12 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build docs | ||
run: yarn install | ||
|
||
- name: Commit and push | ||
uses: khaazz/action-autocommit@master | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: 'auto-commit' | ||
description: 'Commit and push current changes in the repo to the current branch.' | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "action-autocommit", | ||
"version": "1.0.0", | ||
"description": "Action to commit and push changes to the current branch", | ||
"main": "dist/index.js", | ||
"author": "Khaazz <khaaz.dev@gmail.com>", | ||
"license": "MIT", | ||
"scripts": { | ||
"prebuild": "yarn lint", | ||
"build": "ncc build src/main.ts --minify", | ||
"lint": "eslint src --ext .ts" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "^1.0.0", | ||
"@actions/exec": "^1.0.0", | ||
"@actions/io": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@axonteam/eslint-config": "^2.2.0", | ||
"@types/node": "^12.7.2", | ||
"@typescript-eslint/eslint-plugin": "^2.0.0", | ||
"@typescript-eslint/parser": "^2.0.0", | ||
"@zeit/ncc": "^0.20.4", | ||
"eslint": "^6.2.1", | ||
"typescript": "^3.7.2" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@axonteam/eslint-config" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
cd $GITHUB_WORKSPACE | ||
|
||
BRANCH_OR_TAG=`awk -F/ '{print $2}' <<< $GITHUB_REF` | ||
CURRENT_BRANCH=`awk -F/ '{print $NF}' <<< $GITHUB_REF` | ||
|
||
if [ "$BRANCH_OR_TAG" == "heads" ]; then | ||
SOURCE_TYPE="branch" | ||
else | ||
SOURCE_TYPE="tag" | ||
fi | ||
|
||
echo "::[notice] # Pull" | ||
git pull origin $CURRENT_BRANCH | ||
echo "::[notice] # Commit" | ||
git add . | ||
git config user.name "${GITHUB_ACTOR}" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git commit -m "Auto-Commit for ${SOURCE_TYPE} ${CURRENT_BRANCH}: ${GITHUB_SHA}" || true | ||
echo "::[notice] # Push" | ||
git push origin HEAD:${CURRENT_BRANCH} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { resolve } from 'path'; | ||
import { exec } from '@actions/exec'; | ||
import { which } from '@actions/io'; | ||
import { setFailed } from '@actions/core'; | ||
|
||
async function run() { | ||
try { | ||
await exec(await which('bash', true), ['src/commit.sh'], { cwd: resolve(__dirname, '..') } ); | ||
} catch (error) { | ||
setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"target": "es2019", | ||
"lib": [ | ||
"esnext", | ||
"esnext.array", | ||
"esnext.asynciterable", | ||
"esnext.intl", | ||
"esnext.symbol" | ||
], | ||
"sourceMap": false, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"sourceRoot": "/", | ||
"outDir": "dist", | ||
"declaration": false, | ||
"removeComments": false, | ||
"alwaysStrict": true, | ||
"allowSyntheticDefaultImports": true, | ||
"pretty": true | ||
} | ||
} |
Oops, something went wrong.