Skip to content

Commit

Permalink
Rewrite: TypeScript-only (#57)
Browse files Browse the repository at this point in the history
* chore(deps): bump dependecies

* chore: add "inputs" script

* chore: commit local work

* chore: delete lib folder

* chore: commit local work

* BREAKING: edit action options

- force has been deleted, pass the '-f' parameter to add and remove
- ref is now called branch

* [auto] build: update compiled version

* chore: improve input checks

* [auto] build: update compiled version

* fix: pathspec errors should be catched differently

* [auto] build: update compiled version

* fix: check for 'add' and 'remove' before running commands

* [auto] build: update compiled version

* fix: log git commands

* [auto] build: update compiled version

* fix: improve logs' readability

* [auto] build: update compiled version

* chore: try not resetting files

* [auto] build: update compiled version

* fix: ignore errors on 2nd stage, log them on 1st

* [auto] build: update compiled version

* fix: signoff

* [auto] build: update compiled version

* fix: log git tag output

* [auto] build: update compiled version

* fix: use proper method for tagging

* [auto] build: update compiled version

* fix: use dedicated method for pushing tags

* [auto] build: update compiled version

* fix: using pure git tag command is better

* [auto] build: update compiled version

* fix: improve error handling

* [auto] build: update compiled version

* fix: I messed up the lines

* [auto] build: update compiled version

* fix: fix tags push when there's a forced update

* [auto] build: update compiled version

* fix: log errors too

* chore: remove unused dependecy

* [auto] build: update compiled version

* fix: don't log when using ignoreErrors

* [auto] build: update compiled version

* fix: fetch tags

* [auto] build: update compiled version

* fix: try forcing tag fetch

* [auto] build: update compiled version

* fix: try using original command for pushing tags

* [auto] build: update compiled version

* fix: try removing repo from tag command

* [auto] build: update compiled version

* fix: try with object options

* [auto] build: update compiled version

* i don't even know anymore

* [auto] build: update compiled version

* fix: try deleting the tag when it's rejected

* [auto] build: update compiled version

* fix: isolate tag name

* [auto] build: update compiled version

* fix: log result of tag deletion

* [auto] build: update compiled version

* fix: use actual values instead of references

* [auto] build: update compiled version

* fix: join netrc path with module

* [auto] build: update compiled version

* fix-: try not using .netrc at all

* [auto] build: update compiled version

* fix: remove .netrc config

* [auto] build: update compiled version

* chore: remove old shell file

* docs: update README

* chore: fix typo in action manifest

* chore: move ncc to dev-deps

* fix: cwd not working properly

* [auto] build: update compiled version
  • Loading branch information
EndBug authored Sep 25, 2020
1 parent c7b6856 commit 8693022
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 715 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"new-cap": 0,
"no-caller": 2,
"no-undef": 2,
"no-unused-vars": 1,
"no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": "warn",
"no-empty": [
"error",
{
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ jobs:
name: Build compiled JS version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install dependencies
run: npm install
- run: npm install

- name: Compile TypeScript into compressed JavaScript
run: npm run build
- run: npm run build

- name: Commit changes
uses: EndBug/add-and-commit@v4
- uses: EndBug/add-and-commit@v4
with:
message: "[auto] build: update compiled version"
message: '[auto] build: update compiled version'
add: lib
force: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: EndBug/add-and-commit@v4
with:
message: '[auto] build: update input typings'
add: src/inputs.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This action lets you choose the path that you want to use when adding & committi
Add a step like this to your workflow:

```yaml
- uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
with:
# The arguments for the `git add` command (see the paragraph below for more info)
# Default: '.'
Expand All @@ -26,33 +26,29 @@ Add a step like this to your workflow:
# Default: author of the commit that triggered the run
author_email: mail@example.com

# Name of the branch to use, if different from the one that triggered the workflow
# Default: the branch that triggered the run
branch: some-branch

# The local path to the directory where your repository is located. You should use actions/checkout first to set it up
# Default: '.'
cwd: './path/to/the/repo'

# Whether to use the --force option on `git add`, in order to bypass eventual gitignores
# Default: false
force: true

# Whether to use the --signoff option on `git commit`
# Default: false
signoff: true

# The message for the commit
# Default: 'Commit from GitHub Actions'
message: 'Your commit message'

# Name of the branch to use, if different from the one that triggered the workflow
# Default: the branch that triggered the workflow (from GITHUB_REF)
ref: 'someOtherBranch'

# The arguments for the `git rm` command (see the paragraph below for more info)
# Default: ''
remove: "./dir/old_file.js"

# Name of the tag to add to the new commit (see the paragraph below for more info)
# Whether to use the --signoff option on `git commit` (only `true` and `false` are accepted)
# Default: false
signoff: true

# Arguments for the git tag command (the tag name always needs to be the first word not preceded by an hyphen)
# Default: ''
tag: "v1.0.0"
tag: "v1.0.0 --force"

env:
# This is necessary in order to push a commit to the repo
Expand All @@ -66,18 +62,17 @@ That said, you can just copy the example line and not worry about it. If you do

### Adding files:

The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you don't want it to use a recursive behavior: `$(find . -maxdepth 1 -name *.js)`.
The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you want to force-add a file: `./path/to/file.txt --force`.
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.

### Deleting files:

You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal.
You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal. As with the `add` argument, you can use every option `git rm` allows (e.g. add `--force` to ignore `.gitignore` rules).
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.

### Tagging:

You can tag commits with the `tag` option: when used, it will create a lightweight tag for the commit with the name you set as input. If not entered (or if an empty string is passed) teh action won't create any tag.
If there is already a tag with the name you entered it will be overwritten, and so the tag will be "updated".
You can use the `tag` option to enter the arguments for a `git add` command. In order for the action to isolate the tag name from the rest of the arguments, it should be the first word not preceded by an hyphen (e.g. `-a tag-name -m "some other stuff"` is ok).

### Examples:

Expand Down Expand Up @@ -107,7 +102,7 @@ jobs:
run: eslint "src/**" --fix
- name: Commit changes
uses: EndBug/add-and-commit@v4
uses: EndBug/add-and-commit@v5
with:
author_name: Your Name
author_email: mail@example.com
Expand Down Expand Up @@ -138,12 +133,11 @@ jobs:
- run: echo "123" > ./pathToRepo/file.txt
# ...and then use the action as you would normally do, but providing the path to the repo
- uses: EndBug/add-and-commit@v4
- uses: EndBug/add-and-commit@v5
with:
message: "Add the very useful text file"
add: "*.txt"
add: "*.txt --force"
cwd: "./pathToRepo/"
force: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
25 changes: 9 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,33 @@ inputs:
add:
description: Arguments for the git add command
required: false
default: "."
default: '.'
author_name:
description: The name of the user that will be displayed as the author of the commit
required: false
author_email:
description: The email of the user that will be displayed as the author of the commit
required: false
branch:
description: Name of the branch to use, if different from the one that triggered the workflow
required: false
cwd:
description: The directory where your repository is located. You should use actions/checkout first to set it up
required: false
default: "."
force:
description: Whether to use the force option on git add, in order to bypass eventual gitignores
required: false
default: "false"
signoff:
description: Whether to use the signoff option on git commit
required: false
default: "false"
default: '.'
message:
description: The message for the commit
required: false
default: Commit from GitHub Actions
ref:
description: Name of the branch to use, if different from the one that triggered the workflow
required: false
remove:
description: Arguments for the git rm command
required: false
default: ""
signoff:
description: Whether to use the --signoff option on git commit
required: false
tag:
description: The name of the tag to add to the new commit
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
required: false
default: ""

runs:
using: node12
Expand Down
Empty file removed lib/.gitkeep
Empty file.
88 changes: 0 additions & 88 deletions lib/entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8693022

Please sign in to comment.