Skip to content

Commit f2c46c4

Browse files
author
sangeet-joy_xero
committed
updated the version update workflow
1 parent 5796ceb commit f2c46c4

File tree

1 file changed

+59
-100
lines changed

1 file changed

+59
-100
lines changed

.github/workflows/update-yaml-version.yml

Lines changed: 59 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -31,112 +31,71 @@ jobs:
3131
head -n 20 xero_assets.yaml
3232
3333
34-
- name: Install octokit dependencies
35-
run: npm i
36-
working-directory: ${{ github.workspace }}/.github/octokit
37-
38-
- name: Get github app access token
39-
id: get_access_token
40-
env:
41-
GITHUB_APP_ID: ${{ secrets.XERO_GITHUB_APP_ID }}
42-
GITHUB_APP_PRIVATE_KEY: ${{ secrets.XERO_GITHUB_APPLICATION_KEY }}
43-
uses: actions/github-script@v7
44-
with:
45-
result-encoding: string
46-
script: |
47-
const { getAccessToken } = await import('${{ github.workspace }}/.github/octokit/index.js')
48-
const token = await getAccessToken()
49-
return token
50-
51-
52-
- name: Checkout codegen repo
53-
uses: actions/checkout@v4
54-
with:
55-
repository: xero-internal/xeroapi-sdk-codegen
56-
path: xeroapi-sdk-codegen
57-
token: ${{steps.get_access_token.outputs.result}}
58-
59-
- name: checking current dir
34+
- name: Identify the branch name
35+
id: identify_branch_name
36+
working-directory: xeroapi-sdk-codegen/ruby/scripts
6037
run: |
61-
ls
38+
branch_name='OAS-version-update-10.3.7'
39+
echo "branchName=$branch_name" >> $GITHUB_OUTPUT
6240
63-
# - name: Checking existing PR
64-
# shell: bash
65-
# id: check-pr
66-
# run: |
67-
# BRANCH_NAME='OAS-version-update-10.1.0'
68-
# TARGET_BRANCH='master'
69-
# PR_EXISTS=$(gh pr list --head "$BRANCH_NAME" --base "$TARGET_BRANCH" --json number --jq '. | length')
70-
71-
# if [ "$PR_EXISTS" -gt 0 ]; then
72-
# echo "PR already exists"
73-
# echo "pr_exists=true" >> $GITHUB_OUTPUT
74-
# else
75-
# echo "No PR exists"
76-
# echo "pr_exists=false" >> $GITHUB_OUTPUT
77-
# fi
78-
# env:
79-
# GITHUB_TOKEN: ${{ github.token }}
80-
81-
# - name: Checkout branch
82-
# working-directory: xero-ruby
83-
# run: |
84-
# if [ "${{github.event_name}}" == "push" ]; then
85-
# if git ls-remote --heads origin ${{steps.identify_branch_name.outputs.branchName}} | grep -q "refs/heads/${{steps.identify_branch_name.outputs.branchName}}"; then
86-
# echo "checking out existing branch"
87-
# git fetch origin > /dev/null 2>&1
88-
# git checkout ${{steps.identify_branch_name.outputs.branchName}}
89-
# else
90-
# echo "branch does not exists, creating new branch"
91-
# git checkout -b ${{steps.identify_branch_name.outputs.branchName}}
92-
# fi
93-
# fi
41+
- name: Checkout branch
42+
run: |
43+
if [ "${{github.event_name}}" == "push" ]; then
44+
if git ls-remote --heads origin ${{steps.identify_branch_name.outputs.branchName}} | grep -q "refs/heads/${{steps.identify_branch_name.outputs.branchName}}"; then
45+
echo "checking out existing branch"
46+
git fetch origin > /dev/null 2>&1
47+
git checkout ${{steps.identify_branch_name.outputs.branchName}}
48+
else
49+
echo "branch does not exists, creating new branch"
50+
git checkout -b ${{steps.identify_branch_name.outputs.branchName}}
51+
fi
52+
fi
9453
95-
# - name: Staging & commiting
96-
# id: detect-changes
97-
# shell: bash
98-
# run: |
99-
# CHANGES_DETECTED=$(git diff)
100-
# if [ -z "$CHANGES_DETECTED" ]; then
101-
# echo "no new changes, nothing to commit"
102-
# echo "changes_detected=false" >> $GITHUB_OUTPUT
103-
# else
104-
# echo "changes_detected=true" >> $GITHUB_OUTPUT
105-
# echo "running the git commands......"
54+
- name: Staging & commiting
55+
id: detect-changes
56+
shell: bash
57+
run: |
58+
CHANGES_DETECTED=$(git diff)
59+
if [ -z "$CHANGES_DETECTED" ]; then
60+
echo "no new changes, nothing to commit"
61+
echo "changes_detected=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "changes_detected=true" >> $GITHUB_OUTPUT
64+
echo "running the git commands......"
10665
107-
# echo 'staging the changes'
108-
# git add --all
66+
echo 'staging the changes'
67+
git add --all
10968
110-
# echo 'git status'
111-
# git diff
69+
echo 'git status'
70+
git diff
11271
113-
# echo "git config setup"
114-
# git config --global user.name "Github Actions"
115-
# git config --global user.email "actions@github.com"
72+
echo "git config setup"
73+
git config --global user.name "Github Actions"
74+
git config --global user.email "actions@github.com"
11675
117-
# echo 'commiting changes....'
118-
# git commit -m "chore: version update for all the yaml files"
119-
# fi
76+
echo 'commiting changes....'
77+
git commit -m "chore: version update for all the yaml files"
78+
fi
12079
121-
# - name: Pushing the Branch
122-
# shell: bash
123-
# run: |
124-
# if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
125-
# echo "pushing the code to OAS-version-update-10.1.0"
126-
# git push origin OAS-version-update-10.1.0
127-
# fi
80+
- name: Pushing the Branch
81+
shell: bash
82+
run: |
83+
if [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
84+
echo "pushing the code to ${{steps.identify_branch_name.outputs.branchName}} "
85+
git push origin ${{steps.identify_branch_name.outputs.branchName}}
86+
fi
12887
129-
# - name: Create PR
130-
# shell: bash
131-
# run: |
132-
# if [ "${{steps.check-pr.outputs.pr_exists}}" == "false" ] && [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
133-
# echo "Creating PR in OAS-version-update-10.1.0"
134-
# gh pr create \
135-
# --title "OAS version update" \
136-
# --base master \
137-
# --head OAS-version-update-10.1.0 \
138-
# EOF
139-
# )"
140-
# fi
141-
# env:
142-
# GITHUB_TOKEN: ${{ github.token }}
88+
- name: Create PR
89+
shell: bash
90+
run: |
91+
if [ "${{steps.check-pr.outputs.pr_exists}}" == "false" ] && [ "${{steps.detect-changes.outputs.changes_detected}}" == "true" ]; then
92+
echo "Creating PR in OAS-version-update-10.1.0"
93+
gh pr create \
94+
--title "OAS version update" \
95+
--base master \
96+
--head OAS-version-update-10.1.0 \
97+
EOF
98+
)"
99+
fi
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)