mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2026-01-11 12:08:25 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09d175379e | ||
|
|
cdb861eda0 | ||
|
|
6a853b60cc | ||
|
|
76f50fc3ad | ||
|
|
9b4acb8f10 | ||
|
|
d11ccd183d | ||
|
|
a156a1072e | ||
|
|
d69e5f0850 | ||
|
|
86f0c11c06 | ||
|
|
eda98fb9e5 | ||
|
|
844e852dde | ||
|
|
cca75e0840 | ||
|
|
ef107e1d4b | ||
|
|
e97d20ce65 | ||
|
|
3c9d7dd29d | ||
|
|
4ff392a586 | ||
|
|
69c53bd75e |
29
.github/workflows/continuous-deployment.yml
vendored
Normal file
29
.github/workflows/continuous-deployment.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
||||||
|
|
||||||
|
name: "Continuous Deployment"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: "Release"
|
||||||
|
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Determine tag"
|
||||||
|
id: "determine-tag"
|
||||||
|
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""
|
||||||
|
|
||||||
|
- name: "Create release"
|
||||||
|
uses: "actions/create-release@v1.0.0"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
with:
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
release_name: "${{ steps.determine-tag.outputs.tag }}"
|
||||||
|
tag_name: "${{ steps.determine-tag.outputs.tag }}"
|
||||||
@@ -4,10 +4,15 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...HEAD)
|
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.0.0...HEAD)
|
||||||
|
|
||||||
> TBD
|
> TBD
|
||||||
|
|
||||||
|
## [v4.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...v4.0.0) - 2020-02-24
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Switch Action to use `node12`-environment instead of `docker`.
|
||||||
|
|
||||||
## [v3.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...v3.0.0) - 2020-02-06
|
## [v3.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...v3.0.0) - 2020-02-06
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
16
Dockerfile
16
Dockerfile
@@ -1,16 +0,0 @@
|
|||||||
FROM alpine/git:1.0.7
|
|
||||||
|
|
||||||
LABEL "com.github.actions.name"="Auto Commit changed files"
|
|
||||||
LABEL "com.github.actions.description"="Automatically commits files which have been changed during the workflow run and push changes back to remote repository."
|
|
||||||
LABEL "com.github.actions.icon"="git-commit"
|
|
||||||
LABEL "com.github.actions.color"="orange"
|
|
||||||
|
|
||||||
LABEL "repository"="http://github.com/stefanzweifel/git-auto-commit-action"
|
|
||||||
LABEL "homepage"="http://github.com/stefanzweifel/git-auto-commit-action"
|
|
||||||
LABEL "maintainer"="Stefan Zweifel <hello@stefanzweifel.io>"
|
|
||||||
|
|
||||||
RUN apk add git-lfs
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
|
||||||
51
README.md
51
README.md
@@ -17,7 +17,7 @@ This Action has been inspired and adapted from the [auto-commit](https://github.
|
|||||||
Add the following step at the end of your job.
|
Add the following step at the end of your job.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
commit_message: Apply automatic changes
|
commit_message: Apply automatic changes
|
||||||
|
|
||||||
@@ -42,15 +42,18 @@ Add the following step at the end of your job.
|
|||||||
|
|
||||||
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
|
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
|
||||||
|
|
||||||
It is recommended to use this Action in Workflows which listen to the `pull_request` event. If you want to use the Action on other events, you have to hardcode the value for `branch` as `github.head_ref` is only available in Pull Requests.
|
We recommend to use this Action in Workflows, which listen to the `pull_request` event. You can then use the option `branch: ${{ github.head_ref }}` to set up the branch name correctly.
|
||||||
|
If you don't pass a branch name, the Action will try to push the commit to a branch with the same name, as with wich the repo has been checked out.
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
This Action will only work, if the job in your Workflow changes project files.
|
This Action will only work, if the job in your Workflow changes files.
|
||||||
The most common use case for this, is when you're running a Linter or Code-Style fixer on GitHub Actions.
|
The most common use case for this, is when you're running a Linter or Code-Style fixer on GitHub Actions.
|
||||||
|
|
||||||
In this example I'm running `php-cs-fixer` in a PHP project.
|
In this example I'm running `php-cs-fixer` in a PHP project.
|
||||||
|
|
||||||
|
### Example on `pull_request` event
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: php-cs-fixer
|
name: php-cs-fixer
|
||||||
|
|
||||||
@@ -68,12 +71,14 @@ jobs:
|
|||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
branch: ${{ github.head_ref }}
|
branch: ${{ github.head_ref }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Example on `push` event
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: php-cs-fixer
|
name: php-cs-fixer
|
||||||
|
|
||||||
@@ -89,7 +94,7 @@ jobs:
|
|||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
```
|
```
|
||||||
@@ -100,7 +105,41 @@ Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
- If your Workflow can't push the commit to the repository because of authentication issues, please update your Workflow configuration and usage of [`ations/checkout`](https://github.com/actions/checkout#usage). (Updating the `token` value with a Personal Access Token should fix your issues)
|
### Can't push commit to repository
|
||||||
|
If your Workflow can't push the commit to the repository because of authentication issues, please update your Workflow configuration and usage of [`actions/checkout`](https://github.com/actions/checkout#usage). (Updating the `token` value with a Personal Access Token should fix your issues)
|
||||||
|
|
||||||
|
### Commit of this Action does not trigger a new Workflow run
|
||||||
|
As mentioned in the [Usage](#Usage) section, the commit created by this Action **will not trigger** a new Workflow run automatically.
|
||||||
|
|
||||||
|
This is due to limitations set up by GitHub:
|
||||||
|
|
||||||
|
> An action in a workflow run can't trigger a new workflow run. For example, if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
|
||||||
|
[Source](https://help.github.com/en/actions/reference/events-that-trigger-workflows)
|
||||||
|
|
||||||
|
You can change this by creating a new [Pesonal Access Token (PAT)](https://github.com/settings/tokens/new), storing the token as a secret in your repository and then passing the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action.
|
||||||
|
|
||||||
|
#### Example Workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: php-cs-fixer
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
php-cs-fixer:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
|
|
||||||
|
- name: Run php-cs-fixer
|
||||||
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
||||||
|
with:
|
||||||
|
commit_message: Apply php-cs-fixer changes
|
||||||
|
```
|
||||||
|
|
||||||
## Known Issues
|
## Known Issues
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ inputs:
|
|||||||
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'node12'
|
||||||
image: 'Dockerfile'
|
main: 'index.js'
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: 'git-commit'
|
icon: 'git-commit'
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ _switch_to_repository() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_git_is_dirty() {
|
_git_is_dirty() {
|
||||||
[[ -n "$(git status -s)" ]]
|
[ -n "$(git status -s)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set up git user configuration
|
# Set up git user configuration
|
||||||
|
|||||||
34
index.js
Normal file
34
index.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Most of this code has been copied from the following GitHub Action
|
||||||
|
* to make it simpler or not necessary to install a lot of
|
||||||
|
* JavaScript packages to execute a shell script.
|
||||||
|
*
|
||||||
|
* https://github.com/ad-m/github-push-action/blob/fe38f0a751bf9149f0270cc1fe20bf9156854365/start.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const exec = (cmd, args=[]) => new Promise((resolve, reject) => {
|
||||||
|
console.log(`Started: ${cmd} ${args.join(" ")}`)
|
||||||
|
const app = spawn(cmd, args, { stdio: 'inherit' });
|
||||||
|
app.on('close', code => {
|
||||||
|
if(code !== 0){
|
||||||
|
err = new Error(`Invalid status code: ${code}`);
|
||||||
|
err.code = code;
|
||||||
|
return reject(err);
|
||||||
|
};
|
||||||
|
return resolve(code);
|
||||||
|
});
|
||||||
|
app.on('error', reject);
|
||||||
|
});
|
||||||
|
|
||||||
|
const main = async () => {
|
||||||
|
await exec('bash', [path.join(__dirname, './entrypoint.sh')]);
|
||||||
|
};
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
console.error(err.stack);
|
||||||
|
process.exit(err.code || -1);
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user