Skip to content

Commit 4b1aa5c

Browse files
authored
Merge pull request #199 from actions/jcambass/2024-09-16/do-not-check-for-action-yml
Do not assume action.yml exists
2 parents d34ce15 + 2acc8d8 commit 4b1aa5c

File tree

5 files changed

+2
-46
lines changed

5 files changed

+2
-46
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uses: actions/checkout@v4
5252
- name: Publish
5353
id: publish
54-
uses: actions/[email protected].2
54+
uses: actions/[email protected].3
5555
```
5656
<!-- end usage -->
5757

__tests__/fs-helper.test.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ describe('stageActionFiles', () => {
2424
fs.rmSync(stagingDir, { recursive: true })
2525
})
2626

27-
it('returns an error if no action.yml file is present', () => {
28-
expect(() => fsHelper.stageActionFiles(sourceDir, stagingDir)).toThrow(
29-
/^No action.yml or action.yaml file found in source repository/
30-
)
31-
})
32-
3327
it('copies all files (excluding the .git folder) to the staging directory', () => {
3428
fs.writeFileSync(`${sourceDir}/action.yml`, fileContent)
3529

@@ -50,23 +44,6 @@ describe('stageActionFiles', () => {
5044
// .git folder is not copied
5145
expect(fs.existsSync(`${stagingDir}/.git`)).toBe(false)
5246
})
53-
54-
it('copies all files (excluding the .git folder) to the staging directory, even if action.yml is in a subdirectory', () => {
55-
fs.mkdirSync(`${sourceDir}/my-sub-action`, { recursive: true })
56-
fs.writeFileSync(`${sourceDir}/my-sub-action/action.yml`, fileContent)
57-
58-
fsHelper.stageActionFiles(sourceDir, stagingDir)
59-
expect(fs.existsSync(`${stagingDir}/src/main.js`)).toBe(true)
60-
expect(fs.existsSync(`${stagingDir}/src/other.js`)).toBe(true)
61-
expect(fs.existsSync(`${stagingDir}/my-sub-action/action.yml`)).toBe(true)
62-
})
63-
64-
it('accepts action.yaml as a valid action file as well as action.yml', () => {
65-
fs.writeFileSync(`${sourceDir}/action.yaml`, fileContent)
66-
67-
fsHelper.stageActionFiles(sourceDir, stagingDir)
68-
expect(fs.existsSync(`${stagingDir}/action.yaml`)).toBe(true)
69-
})
7047
})
7148

7249
describe('createArchives', () => {

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fs-helper.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,11 @@ export function readFileContents(filePath: string): Buffer {
9191
}
9292

9393
// Copy actions files from sourceDir to targetDir, excluding the .git folder.
94-
// Errors if the repo appears to not contain any action files, such as an action.yml file
9594
export function stageActionFiles(actionDir: string, targetDir: string): void {
96-
let actionYmlFound = false
97-
9895
fsExtra.copySync(actionDir, targetDir, {
9996
filter: (src: string) => {
10097
const basename = path.basename(src)
10198

102-
if (basename === 'action.yml' || basename === 'action.yaml') {
103-
actionYmlFound = true
104-
}
105-
10699
// Filter out the .git folder.
107100
if (basename === '.git') {
108101
return false
@@ -111,12 +104,6 @@ export function stageActionFiles(actionDir: string, targetDir: string): void {
111104
return true
112105
}
113106
})
114-
115-
if (!actionYmlFound) {
116-
throw new Error(
117-
`No action.yml or action.yaml file found in source repository`
118-
)
119-
}
120107
}
121108

122109
// Ensure the correct SHA is checked out for the tag by inspecting the git metadata in the workspace

0 commit comments

Comments
 (0)