-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Add tranform to upgrade artifact actions to v4.
- Loading branch information
1 parent
94840ec
commit 7a74c2c
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import replace from '../lib/text/replace.js'; | ||
import find from '../lib/text/find.js'; | ||
|
||
export const description = 'Upgrade artifact actions to v4.'; | ||
|
||
export const commit = { | ||
type: 'config', | ||
scope: 'ci', | ||
subject: description, | ||
}; | ||
|
||
const workflowFile = '.github/workflows/ci.yml'; | ||
const action = (name, version) => `uses: actions/${name}-artifact@${version}`; | ||
|
||
export async function postcondition({read, assert}) { | ||
assert( | ||
await find([action('upload', 'v4')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
}), | ||
); | ||
assert( | ||
await find([action('download', 'v4')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
}), | ||
); | ||
assert( | ||
!(await find([action('upload', 'v3')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
})), | ||
); | ||
assert( | ||
!(await find([action('download', 'v3')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
})), | ||
); | ||
} | ||
|
||
export async function precondition({read, assert}) { | ||
assert( | ||
await find([action('upload', 'v3')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
}), | ||
); | ||
assert( | ||
await find([action('download', 'v3')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
}), | ||
); | ||
assert( | ||
!(await find([action('upload', 'v4')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
})), | ||
); | ||
assert( | ||
!(await find([action('download', 'v4')], [workflowFile], { | ||
read, | ||
method: find.exact, | ||
})), | ||
); | ||
} | ||
|
||
export async function apply({read, write}) { | ||
await replace( | ||
[ | ||
[action('upload', 'v3'), () => action('upload', 'v4')], | ||
[action('download', 'v3'), () => action('download', 'v4')], | ||
], | ||
[workflowFile], | ||
{ | ||
read, | ||
write, | ||
method: replace.all, | ||
}, | ||
); | ||
} | ||
|
||
export const dependencies = ['ava:test-build']; |