Skip to content

Commit

Permalink
fix build branch name (#208)
Browse files Browse the repository at this point in the history
* fix build branch name

Signed-off-by: Mingshi Liu <[email protected]>

* test workflow with new pushes

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
  • Loading branch information
mingshl authored May 26, 2023
1 parent bde3f40 commit 3b58246
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/remote-integ-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ jobs:

- uses: actions/checkout@v2
- name: Fetch Version Information
id: fetch version
id: fetch_version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Base branch name is $(basename "${{ github.ref }}")"
BRANCH_NAME=$(basename "${{ github.ref }}")
if [[ "${{ github.event_name }}" == "push" ]]; then
pr_number=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
| jq -r '.[0].number')
url_number=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
| jq -r '.[0].url')
pr_data=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"$url_number")
BRANCH_NAME=$(echo "$pr_data" | jq -r '.base.ref')
echo "BRANCH_NAME is $BRANCH_NAME"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Base branch name is "${{ github.event.pull_request.base.ref }}""
BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
fi
fi
CURRENT_VERSION=$(node -p "require('./package.json').version")
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
Expand All @@ -50,6 +58,7 @@ jobs:
echo "OPENSEARCH_DASHBOARDS_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
echo "OPENSEARCH_DASHBOARDS_FTREPO_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
echo "SEARCH_PROCESSOR_PLUGIN_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
shell: bash

- name: Enable longer filenames
if: ${{ matrix.os == 'windows-latest' }}
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ jobs:
shell: bash
run: |
OPENSEARCH_PLUGIN_VERSION=$(node -p "require('./package.json').version")
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Base branch name is $(basename "${{ github.ref }}")"
BRANCH_NAME=$(basename "${{ github.ref }}")
if [[ "${{ github.event_name }}" == "push" ]]; then
pr_number=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
| jq -r '.[0].number')
url_number=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
| jq -r '.[0].url')
pr_data=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"$url_number")
echo "BRANCH_NAME is $BRANCH_NAME"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Base branch name is "${{ github.event.pull_request.base.ref }}""
BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
fi
fi
echo "Target branch: $BRANCH_NAME"
echo "OPENSEARCH_PLUGIN_VERSION=$OPENSEARCH_PLUGIN_VERSION" >> $GITHUB_ENV
echo "OPENSEARCH_VERSION=$BRANCH_NAME" >> $GITHUB_ENV
Expand Down

0 comments on commit 3b58246

Please sign in to comment.