Skip to content

Commit 632994b

Browse files
authored
Enable pipeline on fork repo for testing (twilio#198)
Co-authored-by: chsingh <[email protected]>
1 parent 8ba520b commit 632994b

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const saveFile = require('fs').writeFileSync;
2+
3+
function packageChanges(rootPath, owner) {
4+
const pkgJsonPath = `${rootPath}/package.json`
5+
const json = require(pkgJsonPath);
6+
7+
if (!json.hasOwnProperty('repository')) {
8+
json.repository = {};
9+
json.repository['type'] = 'git'
10+
json.repository['url'] = `https://github.com/${owner}/twilio-cli-core.git`
11+
} else {
12+
json.repository['url'] = `https://github.com/${owner}/twilio-cli-core.git`
13+
}
14+
15+
saveFile(pkgJsonPath, JSON.stringify(json, null, 2));
16+
}
17+
18+
function releasercChanges(rootPath) {
19+
const releasercJsonPath = `${rootPath}/.releaserc.json`
20+
const json = require(releasercJsonPath);
21+
if (json.plugins.includes("@semantic-release/npm")) {
22+
json.plugins = _removeItem(json.plugins, "@semantic-release/npm")
23+
json.plugins.push(["@semantic-release/npm", {"npmPublish": false}])
24+
}
25+
26+
saveFile(releasercJsonPath, JSON.stringify(json, null, 2));
27+
}
28+
29+
function _removeItem(arr, value) {
30+
var index = arr.indexOf(value);
31+
if (index > -1) {
32+
arr.splice(index, 1);
33+
}
34+
return arr;
35+
}
36+
37+
38+
packageChanges(process.argv[2], process.argv[3])
39+
releasercChanges(process.argv[2])

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jobs:
155155
REPO_ACCESS_TOKEN: ${{ github.token }}
156156
TAG_NAME: ${{ steps.semantic-release.outputs.TAG_NAME }}
157157
RELEASE_BODY: ${{needs.update-api-specs.outputs.change-log}}
158-
REPO_NAME: twilio/twilio-cli-core
158+
REPO_NAME: ${{ github.repository }}
159159
triggerCliWorkflow:
160160
runs-on: ubuntu-latest
161161
needs: [ update-api-specs, release]
@@ -173,7 +173,7 @@ jobs:
173173
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
174174
WORKFLOW_NAME: 'release.yml'
175175
BRANCH_NAME: ${{github.event.inputs.cli-branch}}
176-
REPO_NAME: twilio/twilio-cli
176+
REPO_NAME: ${{ github.repository_owner }}/twilio-cli
177177
INPUTS: '{ "change-log": ${{ toJSON(needs.update-api-specs.outputs.change-log) }}, "version-type": "${{needs.update-api-specs.outputs.version-type}}", "homebrew-branch": "${{github.event.inputs.homebrew-branch}}", "homebrew-prerelease": "${{github.event.inputs.homebrew-prerelease}}" }'
178178
notify-complete-fail:
179179
if: ${{ (needs.cli-token-validation.result != 'failure' || needs.cli-core-token-validation.result != 'failure' ) && (failure() || cancelled()) }}

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ test:
1212

1313
clean:
1414
rm -rf node_modules
15+
16+
generate-fork-pipeline-changes:
17+
git co main
18+
node .github/scripts/create-fork-pipeline-changes.js $(PWD) $(owner)

0 commit comments

Comments
 (0)