Deploy and Test Branch #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy and Test Branch | |
on: | |
workflow_call: | |
inputs: | |
netclientbranch: | |
required: true | |
type: string | |
netmakerbranch: | |
type: string | |
required: true | |
tag: | |
type: string | |
required: true | |
workflow_dispatch: | |
inputs: | |
netclientbranch: | |
required: true | |
type: string | |
netmakerbranch: | |
type: string | |
required: true | |
tag: | |
type: string | |
required: true | |
jobs: | |
getserver: | |
runs-on: ubuntu-latest | |
outputs: | |
server: ${{ steps.data.outputs.server }} | |
steps: | |
- name: setup ssh | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.TESTING_SSH_KEY }}" > ~/.ssh/id_devops | |
chmod 600 ~/.ssh/id_devops | |
cat >> ~/.ssh/config <<EOF | |
Host *.clustercat.com | |
StrictHostKeyChecking no | |
UserKnownHostsFile=/dev/null | |
IdentityFile ~/.ssh/id_devops | |
EOF | |
env: | |
TESTING_SSH_KEY: ${{ secrets.TESTING_SSH_KEY }} | |
- name: get server | |
id: data | |
run: | | |
server="" | |
for arg in "1" "2" "3" "4" "5"; do | |
echo checking server $arg | |
result=$( ssh root@server.branch${arg}.clustercat.com /root/branchtesting/check.sh ) | |
echo $result | |
if [ "$result" == "pass" ]; then | |
server=branch${arg} | |
break | |
fi | |
done | |
echo server is $server | |
if [ "$server" == "" ]; then | |
echo "no server found" | |
exit 1 | |
fi | |
echo "server=${server}" >> $GITHUB_OUTPUT | |
echo ${server} >> /tmp/server | |
set +e | |
ssh root@server.${server}.clustercat.com /root/branchtesting/clean.sh | |
exit 0 | |
- name: save server as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: server | |
path: /tmp/server | |
retention-days: 1 | |
terraform: | |
needs: [getserver] | |
uses: gravitl/devops/.github/workflows/terraform.yml@NET-1485-b | |
with: | |
netclientbranch: ${{ inputs.netclientbranch }} | |
netmakerbranch: ${{ inputs.netmakerbranch }} | |
server: ${{ needs.getserver.outputs.server }} | |
secrets: inherit | |
masterkey: | |
needs: [getserver, terraform] | |
runs-on: ubuntu-latest | |
outputs: | |
masterkey: ${{ steps.data.outputs.masterkey }} | |
steps: | |
- name: setup ssh | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.TESTING_SSH_KEY }}" > ~/.ssh/id_devops | |
chmod 600 ~/.ssh/id_devops | |
cat >> ~/.ssh/config <<EOF | |
Host *.clustercat.com | |
StrictHostKeyChecking no | |
UserKnownHostsFile=/dev/null | |
IdentityFile ~/.ssh/id_devops | |
EOF | |
env: | |
TESTING_SSH_KEY: ${{ secrets.TESTING_SSH_KEY }} | |
- name: get master key | |
id: data | |
run: | | |
masterkey=$( ssh root@server.${{ needs.getserver.outputs.server }}.clustercat.com grep MASTER_KEY /root/.env | cut -d= -f2 ) | |
echo "masterkey=${masterkey}" >> $GITHUB_OUTPUT | |
testbranch: | |
needs: [getserver, terraform, masterkey] | |
uses: gravitl/devops/.github/workflows/branchtest.yml@NET-1485-b | |
with: | |
tag: ${{ inputs.tag }} | |
network: netmaker | |
api: "https://api.${{ needs.getserver.outputs.server }}.clustercat.com" | |
masterkey: ${{ needs.masterkey.outputs.masterkey }} | |
server: ${{ needs.getserver.outputs.server }} | |
secrets: inherit |