Skip to content

Commit

Permalink
fix(naming): renamed "deleted" to "removed". sorry if this is breakin…
Browse files Browse the repository at this point in the history
…g for you.
  • Loading branch information
trilom committed Mar 24, 2020
1 parent a9c8658 commit 800537f
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .github/actions/integration/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ testResults () {
result=51
elif [ "$4" == 'files_modified' ]; then
result=12
elif [ "$4" == 'files_deleted' ]; then
elif [ "$4" == 'files_removed' ]; then
result=7
fi
if [ "$2" == 'json' ]; then
Expand Down Expand Up @@ -107,15 +107,15 @@ runTest () {

test () {
if [ "$output" == "" ] || [ "$fileOutput" == "" ]; then
for format in "json" "," " "; do \
for format in "json" "," "\' \'"; do \
echo '\033[1;92mFORMAT:"'$format'"\033[0m'
for file in "files" "files_modified" "files_added" "files_deleted"; do \
for file in "files" "files_modified" "files_added" "files_removed"; do \
echo '\033[1;92mFILE:'$file'\033[0m'
runTest $file "$format" "$format"
done
done
else
for file in "files" "files_modified" "files_added" "files_deleted"; do \
for file in "files" "files_modified" "files_added" "files_removed"; do \
echo '\033[1;92mFILE:'$file'\033[0m'
runTest $file "$fileOutput" "$output"
done
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
files: ${{ format('{0}{1}', toJSON(steps.file_changes_build_pr.outputs.files), toJSON(steps.file_changes_build_push.outputs.files)) }}
files_modified: ${{ format('{0}{1}', toJSON(steps.file_changes_build_pr.outputs.files_modified), toJSON(steps.file_changes_build_push.outputs.files_modified)) }}
files_added: ${{ format('{0}{1}', toJSON(steps.file_changes_build_pr.outputs.files_added), toJSON(steps.file_changes_build_push.outputs.files_added)) }}
files_deleted: ${{ format('{0}{1}', toJSON(steps.file_changes_build_pr.outputs.files_deleted), toJSON(steps.file_changes_build_push.outputs.files_deleted)) }}
files_removed: ${{ format('{0}{1}', toJSON(steps.file_changes_build_pr.outputs.files_removed), toJSON(steps.file_changes_build_push.outputs.files_removed)) }}
- run: chmod +x test.sh && ./test.sh
working-directory: .github/actions/integration
if: success() && matrix.output != 'json'
Expand All @@ -111,4 +111,4 @@ jobs:
files: ${{ format('{0}{1}', steps.file_changes_build_pr.outputs.files, steps.file_changes_build_push.outputs.files ) }}
files_modified: ${{ format('{0}{1}', steps.file_changes_build_pr.outputs.files_modified, steps.file_changes_build_push.outputs.files_modified ) }}
files_added: ${{ format('{0}{1}', steps.file_changes_build_pr.outputs.files_added, steps.file_changes_build_push.outputs.files_added ) }}
files_deleted: ${{ format('{0}{1}', steps.file_changes_build_pr.outputs.files_deleted, steps.file_changes_build_push.outputs.files_deleted ) }}
files_removed: ${{ format('{0}{1}', steps.file_changes_build_pr.outputs.files_removed, steps.file_changes_build_push.outputs.files_removed ) }}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _Optional_ - `string` - pass in a specific PR number to get file changes from.

### files

steps.file_changes.outputs.files - `string` - The names all new, updated, and deleted files. The output is dependant on the output input, default is a json string.
steps.file_changes.outputs.files - `string` - The names all new, updated, and removed files. The output is dependant on the output input, default is a json string.

### files_added

Expand All @@ -54,9 +54,9 @@ steps.file_changes.outputs.files_added - `string` - The names of the newly creat

steps.file_changes.outputs.files_modified - `string` - The names of the updated files. The output is dependant on the output input, default is a json string.

### files_deleted
### files_removed

steps.file_changes.outputs.files_deleted - `string` - The names of the deleted files. The output is dependant on the output input, default is a json string.
steps.file_changes.outputs.files_removed - `string` - The names of the removed files. The output is dependant on the output input, default is a json string.

## Example usage

Expand Down Expand Up @@ -106,9 +106,9 @@ If a push is made then it will compare commits from the SHA `github.payload.befo

After gathering this information it will output the files in 2 ways.

- As an output variable, you can use this variable by using `steps.file_changes_outputs_files`, `steps.file_changes.outputs.files_modified`, `steps.file_changes.outputs.files_added`, `steps.file_changes.outputs.files_deleted`.
- As an output variable, you can use this variable by using `steps.file_changes_outputs_files`, `steps.file_changes.outputs.files_modified`, `steps.file_changes.outputs.files_added`, `steps.file_changes.outputs.files_removed`.

- As a file on the container stored at `$HOME/files.json`, `$HOME/files_modified.json`, `$HOME/files_added.json`, `$HOME/files_deleted.json`.
- As a file on the container stored at `$HOME/files.json`, `$HOME/files_modified.json`, `$HOME/files_added.json`, `$HOME/files_removed.json`.

- _NOTE:_ If you set a custom delimiter in output or fileOutput inputs then you will receive different files. For example a delimiter of ',' will output at `$HOME/files.csv` instead of `$HOME/files.json`. Likewise, anything other than 'json' or ',' delmiters will output `$HOME/files.txt` files instead of `$HOME/files.json` by default.

Expand Down Expand Up @@ -138,11 +138,11 @@ jobs:
cat $HOME/files.json
cat $HOME/files_modified.json
cat $HOME/files_added.json
cat $HOME/files_deleted.json
cat $HOME/files_removed.json
echo '${{ steps.file_changes.outputs.files}}'
echo '${{ steps.file_changes.outputs.files_modified}}'
echo '${{ steps.file_changes.outputs.files_added}}'
echo '${{ steps.file_changes.outputs.files_deleted}}'
echo '${{ steps.file_changes.outputs.files_removed}}'
```

You can set the output and fileOutput to ',' for csv output.
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'File Changes Action'
description: 'Creates outputs variables of files modified, added, or deleted by a PR or Push.'
description: 'Creates outputs variables of files modified, added, or removed by a PR or Push.'
author: 'Bryan Killian <me@trilom.org>'
inputs:
githubRepo:
Expand All @@ -26,13 +26,13 @@ inputs:
required: false
outputs:
files:
description: 'The names all new, updated, and deleted files'
description: 'The names all new, updated, and removed files'
files_added:
description: 'The names of the newly created files'
files_modified:
description: 'The names of the updated files'
files_deleted:
description: 'The names of the deleted files'
files_removed:
description: 'The names of the removed files'
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"engines": {
"node": "12.16.1"
},
"description": "Creates outputs variables of files modified, added, or deleted by a PR or Push.",
"description": "Creates outputs variables of files modified, added, or removed by a PR or Push.",
"main": "lib/main.js",
"scripts": {
"build": "yarn && tsc",
Expand Down
6 changes: 3 additions & 3 deletions src/FilesHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {getErrorString} from './UtilsHelper'
/**
* @function sortChangedFiles
* @param files pass in array of GithubFile's to be sorted
* @returns ChangedFiles object that has .files, .added, .modified, and .deleted
* @returns ChangedFiles object that has .files, .added, .modified, and .removed
*/
export function sortChangedFiles(files: GitHubFile[]): ChangedFiles {
try {
Expand Down Expand Up @@ -78,7 +78,7 @@ export function formatChangedFiles(format: string, files: string[]): string {
/**
* @function writeFiles
* @param format output format 'json' will stringify anything else will files.join('string')
* @param key changedFiles type added, modified, deleted, or files
* @param key changedFiles type added, modified, removed, or files
* @param files string list of files to format
* @returns string output to be stored in file
*/
Expand Down Expand Up @@ -113,7 +113,7 @@ export function writeFiles(format: string, key: string, files: string[]): void {
/**
* @function writeOutput
* @param format output format 'json' will stringify anything else will files.join('string')
* @param key changedFiles type added, modified, deleted, or files
* @param key changedFiles type added, modified, removed, or files
* @param files string list of files to format
* @returns string output to be stored to action output
*/
Expand Down
2 changes: 1 addition & 1 deletion src/tests/mocks/octokit/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const weirdFileArray: string[] = [
".github/actions/deploy_infrastruc1234'ture/deploy.sh",
'.github/actions/make_commands/&&&index.js',
'.github/actions/make_comdf&*(@mands/test/files_added.json',
'.github/actions/make_c``ommands/test/files_deleted.json',
'.github/actions/make_c``ommands/test/files_removed.json',
'.github/actions/make commands/test/files_modified.json',
'.pre-commit-config.yaml',
'cloudformation/Makefile',
Expand Down

0 comments on commit 800537f

Please sign in to comment.