Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manual trigger getbranch logic change #3119

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions .github/workflows/branchtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,40 @@ jobs:
if: ${{ needs.skip-check.outputs.skip != 'true' }}
outputs:
netclientbranch: ${{ steps.getbranch.outputs.netclientbranch }}
netmakerbranch: ${{ steps.getbranch.outputs.netmakerbranch }}
steps:
- name: checkout
- name: Determine branches
id: determine_branches
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "NETMAKER_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "NETCLIENT_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
else
echo "NETMAKER_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "NETCLIENT_BRANCH=develop" >> $GITHUB_ENV
fi
- name: Checkout netclient repository
uses: actions/checkout@v4
with:
repository: gravitl/netclient
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || 'develop' }}
- name: check if branch exists
fetch-depth: 0
- name: Check if netclient branch exists and set output
id: getbranch
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
BRANCH="${{ github.event.inputs.branch }}"
else
BRANCH="${{ github.head_ref }}"
fi
if git show-ref ${{ github.head_ref}}; then
echo branch exists
echo "netclientbranch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
if git ls-remote --heads origin ${{ env.NETCLIENT_BRANCH }} | grep -q ${{ env.NETCLIENT_BRANCH }}; then
echo "netclient branch ${{ env.NETCLIENT_BRANCH }} exists"
echo "netclientbranch=${{ env.NETCLIENT_BRANCH }}" >> $GITHUB_OUTPUT
else
echo branch does not exist
echo "netclient branch ${{ env.NETCLIENT_BRANCH }} does not exist, using develop"
echo "netclientbranch=develop" >> $GITHUB_OUTPUT
fi
echo "netmakerbranch=${{ env.NETMAKER_BRANCH }}" >> $GITHUB_OUTPUT

branchtest:
uses: gravitl/devops/.github/workflows/testdeploybranch.yml@master
needs: [getbranch, skip-check]
with:
netclientbranch: ${{ needs.getbranch.outputs.netclientbranch }}
netmakerbranch: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.head_ref }}
netmakerbranch: ${{ needs.getbranch.outputs.netmakerbranch }}
tag: ${{ github.run_id }}-${{ github.run_attempt }}
secrets: inherit
secrets: inherit
Loading