|
@@ -1,38 +1,19 @@
|
|
name: Deploy and Test Branch
|
|
name: Deploy and Test Branch
|
|
|
|
|
|
on:
|
|
on:
|
|
- pull_request_review:
|
|
|
|
- types: [submitted]
|
|
|
|
- pull_request_target:
|
|
|
|
- types: [opened, synchronize, reopened]
|
|
|
|
workflow_dispatch:
|
|
workflow_dispatch:
|
|
inputs:
|
|
inputs:
|
|
branch:
|
|
branch:
|
|
description: 'Branch to deploy and test'
|
|
description: 'Branch to deploy and test'
|
|
required: true
|
|
required: true
|
|
default: 'develop'
|
|
default: 'develop'
|
|
|
|
+ pull_request:
|
|
|
|
+ types: [opened, synchronize, reopened]
|
|
|
|
+ branches: [develop]
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
- check-pr-approval:
|
|
|
|
- runs-on: ubuntu-latest
|
|
|
|
- if: github.event_name != 'workflow_dispatch'
|
|
|
|
- outputs:
|
|
|
|
- approved: ${{ steps.check.outputs.approved }}
|
|
|
|
- steps:
|
|
|
|
- - name: Check if PR is approved or author is a contributor
|
|
|
|
- id: check
|
|
|
|
- run: |
|
|
|
|
- if [[ "${{ github.event.review.state }}" == "approved" ]] || \
|
|
|
|
- [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.author_association }}" =~ ^(OWNER|MEMBER|COLLABORATOR)$ ]]; then
|
|
|
|
- echo "approved=true" >> $GITHUB_OUTPUT
|
|
|
|
- else
|
|
|
|
- echo "approved=false" >> $GITHUB_OUTPUT
|
|
|
|
- fi
|
|
|
|
-
|
|
|
|
skip-check:
|
|
skip-check:
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
- needs: [check-pr-approval]
|
|
|
|
- if: github.event_name == 'workflow_dispatch' || needs.check-pr-approval.outputs.approved == 'true'
|
|
|
|
outputs:
|
|
outputs:
|
|
skip: ${{ steps.skip.outputs.skip }}
|
|
skip: ${{ steps.skip.outputs.skip }}
|
|
steps:
|
|
steps:
|
|
@@ -43,8 +24,8 @@ jobs:
|
|
|
|
|
|
getbranch:
|
|
getbranch:
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
- needs: [skip-check, check-pr-approval]
|
|
|
|
- if: (needs.skip-check.outputs.skip != 'true') && (github.event_name == 'workflow_dispatch' || needs.check-pr-approval.outputs.approved == 'true')
|
|
|
|
|
|
+ needs: skip-check
|
|
|
|
+ if: ${{ needs.skip-check.outputs.skip != 'true' }}
|
|
outputs:
|
|
outputs:
|
|
netclientbranch: ${{ steps.getbranch.outputs.netclientbranch }}
|
|
netclientbranch: ${{ steps.getbranch.outputs.netclientbranch }}
|
|
netmakerbranch: ${{ steps.getbranch.outputs.netmakerbranch }}
|
|
netmakerbranch: ${{ steps.getbranch.outputs.netmakerbranch }}
|
|
@@ -56,16 +37,14 @@ jobs:
|
|
echo "NETMAKER_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
|
echo "NETMAKER_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
|
echo "NETCLIENT_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
|
echo "NETCLIENT_BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
|
|
else
|
|
else
|
|
- echo "NETMAKER_BRANCH=${{ github.event.pull_request.head.ref || github.head_ref }}" >> $GITHUB_ENV
|
|
|
|
|
|
+ echo "NETMAKER_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
|
|
echo "NETCLIENT_BRANCH=develop" >> $GITHUB_ENV
|
|
echo "NETCLIENT_BRANCH=develop" >> $GITHUB_ENV
|
|
fi
|
|
fi
|
|
-
|
|
|
|
- name: Checkout netclient repository
|
|
- name: Checkout netclient repository
|
|
uses: actions/checkout@v4
|
|
uses: actions/checkout@v4
|
|
with:
|
|
with:
|
|
repository: gravitl/netclient
|
|
repository: gravitl/netclient
|
|
fetch-depth: 0
|
|
fetch-depth: 0
|
|
-
|
|
|
|
- name: Check if netclient branch exists and set output
|
|
- name: Check if netclient branch exists and set output
|
|
id: getbranch
|
|
id: getbranch
|
|
run: |
|
|
run: |
|
|
@@ -80,8 +59,7 @@ jobs:
|
|
|
|
|
|
branchtest:
|
|
branchtest:
|
|
uses: gravitl/devops/.github/workflows/testdeploybranch.yml@master
|
|
uses: gravitl/devops/.github/workflows/testdeploybranch.yml@master
|
|
- needs: [getbranch, skip-check, check-pr-approval]
|
|
|
|
- if: (needs.skip-check.outputs.skip != 'true') && (github.event_name == 'workflow_dispatch' || needs.check-pr-approval.outputs.approved == 'true')
|
|
|
|
|
|
+ needs: [getbranch, skip-check]
|
|
with:
|
|
with:
|
|
netclientbranch: ${{ needs.getbranch.outputs.netclientbranch }}
|
|
netclientbranch: ${{ needs.getbranch.outputs.netclientbranch }}
|
|
netmakerbranch: ${{ needs.getbranch.outputs.netmakerbranch }}
|
|
netmakerbranch: ${{ needs.getbranch.outputs.netmakerbranch }}
|