Skip to content

Commit 396b84a

Browse files
Refactoring of workflow file
1 parent ef80e8d commit 396b84a

File tree

1 file changed

+74
-83
lines changed

1 file changed

+74
-83
lines changed

.github/workflows/build.yml

+74-83
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,105 @@
1-
2-
name: Cli-core Build
3-
1+
name: Cli-core Release
42
on:
5-
# repository_dispatch:
6-
# types: [ releaseCliCore ]
7-
# push:
8-
# branches: [ test_branch_actions ]
93
workflow_dispatch:
104
inputs:
11-
cliBranch:
5+
cli-branch:
126
description: 'Run workflow in the branch'
137
default: main
14-
158
jobs:
16-
build:
9+
test:
1710
runs-on: ubuntu-latest
1811
strategy:
1912
matrix:
2013
node-version: [10.x]
2114
steps:
22-
- uses: actions/checkout@v2
23-
- run: npm install
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v2
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
cache: 'npm'
29-
- run: npm ci
30-
- run: npm test
31-
updateAPIDefinitions:
15+
- name: Checkout to cli-core repo
16+
- uses: actions/checkout@v2
17+
- run: npm install
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
- name: Run tests
24+
run: |
25+
npm ci
26+
npm test
27+
update-api-specs:
3228
runs-on: ubuntu-latest
33-
needs: [build]
29+
needs: [test]
3430
outputs:
35-
changeLog: ${{ steps.updateFolder.outputs.changeLog }}
36-
versionType: ${{ steps.updateFolder.outputs.versionType }}
31+
change-log: ${{ steps.update-specs.outputs.change-log }}
32+
version-type: ${{ steps.update-specs.outputs.version-type }}
3733
steps:
38-
- run: mkdir -p ~/oai_definitions/json
39-
- run: cd ~/oai_definitions
40-
- run: pwd
41-
- run: ls
42-
- uses: actions/checkout@v2
43-
with:
44-
repository: 'LakshmiRavali/twilio-oai'
45-
token: ${{ secrets.OAI_TOKEN }}
46-
- run: |
47-
cp -R spec/json/. ~/oai_definitions/json/
48-
cp -R CHANGES.md ~/oai_definitions/CHANGES.md
49-
- uses: actions/checkout@v2
50-
- name: Update OAI folder
51-
id: updateFolder
52-
# run: |
53-
# echo "::set-output name=changeLog::$(git branch --show-current)"
54-
# - run: echo ${{ steps.updateFolder.outputs.changeLog}}
55-
run: |
56-
npm install
57-
cp -R ~/oai_definitions/CHANGES.md OAI_CHANGES.md
58-
source scripts/updateApiDefinitions.sh
59-
echo "::set-output name=changeLog::$changeLog"
60-
echo "::set-output name=versionType::$versionType"
34+
- name: Create temporary folder for copying json files fom OAI repo
35+
- run: mkdir -p ~/oai_definitions/json
36+
- name: Checkout to OAI repo
37+
- uses: actions/checkout@v2
38+
with:
39+
repository: 'LakshmiRavali/twilio-oai'
40+
token: ${{ secrets.OAI_TOKEN }}
41+
- run: |
42+
cp -R spec/json/. ~/oai_definitions/json/
43+
cp -R CHANGES.md ~/oai_definitions/CHANGES.md
44+
- name: Checkout to cli-core repo
45+
- uses: actions/checkout@v2
46+
- name: Update OAI specs
47+
id: update-specs
48+
run: |
49+
npm install
50+
cp -R ~/oai_definitions/CHANGES.md OAI_CHANGES.md
51+
source scripts/updateApiDefinitions.sh
52+
echo "::set-output name=change-log::$changeLog"
53+
echo "::set-output name=version-type::$versionType"
6154
release:
6255
runs-on: ubuntu-latest
63-
needs: [updateAPIDefinitions]
56+
needs: [update-api-specs]
6457
steps:
65-
- uses: actions/checkout@v2
66-
- run: git pull
67-
- run: git branch
68-
- run: git log -3
69-
- run: npm install
70-
- name: Use Node.js ${{ matrix.node-version }}
71-
uses: actions/setup-node@v2
72-
with:
73-
node-version: ${{ matrix.node-version }}
74-
cache: 'npm'
75-
- name: semanticRelease
76-
run: npm install --save-dev @semantic-release/changelog @semantic-release/git
77-
- run: npm ci && npx semantic-release -t \${version}
78-
env:
79-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80-
updateRelease:
58+
- name: Checkout to cli-core repo
59+
- uses: actions/checkout@v2
60+
run: |
61+
git pull
62+
npm install
63+
- name: Use Node.js ${{ matrix.node-version }}
64+
uses: actions/setup-node@v2
65+
with:
66+
node-version: ${{ matrix.node-version }}
67+
cache: 'npm'
68+
- name: semanticRelease
69+
run: |
70+
npm install --save-dev @semantic-release/changelog @semantic-release/git
71+
npm ci && npx semantic-release -t \${version}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
update-release:
8175
runs-on: ubuntu-latest
82-
strategy:
83-
matrix:
84-
node-version: [10.x]
85-
needs: [updateAPIDefinitions, release]
86-
steps:
76+
needs: [update-api-specs, release]
77+
steps:
78+
- name: Checkout to cli-core repo
8779
- uses: actions/checkout@v2
8880
- run: git fetch --tags
89-
- name: Getting tag
90-
id: test
81+
- name: Getting latest tag
82+
id: get-tag
9183
run: |
9284
echo "::set-output name=TAG_NAME::$(git describe --tags $(git rev-list --tags --max-count=1))"
93-
- run: echo "${{steps.test.outputs.TAG_NAME}}"
94-
- name: update release
95-
id: update_release
85+
- run: echo "${{steps.get-tag.outputs.TAG_NAME}}"
86+
- name: Update release
9687
uses: tubone24/[email protected]
9788
env:
9889
GITHUB_TOKEN: ${{ github.token }}
99-
TAG_NAME: ${{steps.test.outputs.TAG_NAME}}
90+
TAG_NAME: ${{steps.get-tag.outputs.TAG_NAME}}
10091
with:
10192
is_append_body: true
102-
body: "${{needs.updateAPIDefinitions.outputs.changeLog}}"
93+
body: ${{needs.update-api-specs.outputs.change-log}}
10394
triggerCliWorkflow:
104-
runs-on: ubuntu-latest
105-
needs: [ updateAPIDefinitions, updateRelease ]
106-
steps:
107-
- name: Invoke CLI workflow with changelog
95+
runs-on: ubuntu-latest
96+
needs: [ update-api-specs, update-release]
97+
steps:
98+
- name: Invoke CLI workflow with changelog and version-type
10899
uses: benc-uk/workflow-dispatch@v1
109100
with:
110-
workflow: Cli Publish
111-
token: ${{ secrets.REPO_ACCESS_TOKEN }}
101+
workflow: Cli Release
102+
token: ${{ secrets.CLI_ACCESS_TOKEN }}
112103
repo: LakshmiRavali/twilio-cli
113-
ref: "${{ github.event.inputs.cliBranch }}"
114-
inputs: '{ "changeLog": ${{ toJSON(needs.updateAPIDefinitions.outputs.changeLog) }}, "versionType": "${{needs.updateAPIDefinitions.outputs.versionType}}" }'
104+
ref: ${{ github.event.inputs.cli-branch }}
105+
inputs: '{ "changeLog": ${{ toJSON(needs.update-api-specs.outputs.change-log) }}, "version-Type": "${{needs.update-api-specs.outputs.version-type}}" }'

0 commit comments

Comments
 (0)