Skip to content

Commit 33d40a7

Browse files
committed
Change action name
1 parent 6e5bc44 commit 33d40a7

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Checkout
8-
uses: actions/checkout@v1
8+
uses: actions/checkout@v2
99
- name: Build
1010
run: |
1111
npm ci
@@ -14,5 +14,6 @@ jobs:
1414
id: migrations
1515
with:
1616
files: '["migrations/test.sql", "package.json"]'
17+
pattern: 'migrations'
1718
- name: Echo output
18-
run: echo ${{ steps.migrations.outputs.content }}
19+
run: echo "{{ steps.migrations.outputs.content }}"

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# read-migration-files-action
1+
# read-files-action
22

3-
Read Django migration files content.
3+
Read files content.
44

55
## Usage
66

77
```yaml
88
steps:
99
- name: Read migrations
1010
id: migrations
11-
uses: komorebitech/read-migration-files-action@v1.4
11+
uses: komorebitech/read-files-action@v1.5
1212
with:
1313
files: '["/migrations/001_initial.py", "/migrations/002_auto_2020_08_11_545462.py"]'
1414
- name: Echo migrations
15-
run: echo ${{ steps.migrations.outputs.content }}
15+
run: echo "{{ steps.migrations.outputs.content }}"
1616
```
1717
1818
## License

action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: Read Migration files action
1+
name: Read files action
22
author: debugger22
3-
description: 'Read Django Migration files content'
3+
description: 'Read files content'
44
branding:
55
icon: 'file'
66
color: yellow
@@ -11,7 +11,7 @@ inputs:
1111
pattern:
1212
description: 'File pattern to match using RegEx'
1313
required: false
14-
default: 'migrations'
14+
default: ''
1515
outputs:
1616
content:
1717
description: 'Concatenated content of the files'

dist/index.js

+29-14
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,40 @@ module.exports = require("os");
5959
const core = __webpack_require__(470);
6060
const { promises: fs } = __webpack_require__(747);
6161

62-
const main = async () => {
63-
const filePaths = JSON.parse(core.getInput('files'));
64-
console.log(filePaths);
65-
var output = "";
62+
const main = () => {
63+
const filePaths = JSON.parse(core.getInput("files"));
64+
const regularExpression = core.getInput("pattern");
6665

67-
filePaths.forEach(async(filePath) => {
66+
const pattern = new RegExp(regularExpression);
6867

69-
if(filePath.includes("migrations")){
70-
output += `========================== ${filePath} ==========================\n\n`;
71-
const content = await fs.readFile(process.env.GITHUB_WORKSPACE + "/" + filePath, 'utf8');
72-
output += content + "\n\n";
68+
console.log(filePaths, pattern);
7369

74-
}
70+
const matchingFilePaths = filePaths
71+
.filter((filePath) => pattern.test(filePath));
7572

76-
});
77-
core.setOutput('content', output);
78-
}
73+
return Promise.all([
74+
Promise.resolve(matchingFilePaths),
75+
...matchingFilePaths.map((filePath) => fs.readFile(process.env.GITHUB_WORKSPACE + "/" + filePath, "utf8"))
76+
]);
77+
78+
};
79+
80+
main()
81+
.then((response) => {
82+
83+
const [matchingFilePaths, ...fileContents] = response;
84+
85+
let output = '';
86+
87+
fileContents.forEach((content, index) => {
88+
output += `========================== ${matchingFilePaths[index]} ==========================\n\n`;
89+
output += content + "\n\n";
90+
})
91+
92+
core.setOutput("content", output);
7993

80-
main().catch(err => core.setFailed(err.message));
94+
})
95+
.catch((err) => core.setFailed(err.message));
8196

8297

8398
/***/ }),

0 commit comments

Comments
 (0)