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

use static server hosts with custom domain #475

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
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
49 changes: 47 additions & 2 deletions .github/workflows/branchtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ jobs:
skip-check:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
skip: ${{ steps.skip.outputs.skip }}
steps:
- id: skip
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'always'

getbranch:
runs-on: ubuntu-latest
needs: skip-check
Expand All @@ -38,12 +39,56 @@ jobs:
echo "netmakerbranch=develop" >> $GITHUB_OUTPUT
fi

getserver:
runs-on: ubuntu-latest
needs: skip-check
if: ${{ needs.skip-check.outputs.skip != 'true' }}
outputs:
netmakerserver: ${{ steps.getserver.outputs.server }}
steps:
- name: setup ssh
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/id_devops
chmod 600 ~/.ssh/id_devops
cat >>~/.ssh/config <<END
Host *.clustercat.com
User root
IdentityFile ~/.ssh/id_devops
StrictHostKeyChecking no
END
env:
SSH_KEY: ${{ secrets.TESTING_SSH_KEY }}
- name: getserver
id: getserver
run: |
server=""
for arg in "branch1" "branch2" "branch3" "branch4" "branch5"; do
echo checking $arg
result=$( ssh root@server.${arg}.clustercat.com '~/branchtesting/check.sh')
echo $result
if [ "$result" == "pass" ]
then
server=$arg
echo $server>>/tmp/server
break
fi
done
echo server is $server
if [ "$server" == "" ]
then
echo server not set
exit 1
fi
echo "netmakerserver=$server" >> $GITHUB_OUTPUT

terraform:
needs: getbranch
needs: [getbranch, getserver]
uses: gravitl/devops/.github/workflows/terraform.yml@master
with:
netclientbranch: ${{ github.head_ref }}
netmakerbranch: ${{ needs.getbranch.outputs.netmakerbranch }}
server: ${{ needs.getserver.outputs.netmakerserver }}
secrets: inherit


Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/deletedroplets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
with:
run_id: ${{ github.event.workflow_run.id}}
if_no_artifact_found: warn
- name: get server name
run: |
echo "SERVER=$(cat ./server/server) >> $GITHUB_ENV"
- name: get PR
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -42,6 +45,14 @@ jobs:
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
- name: mark server as available
uses: appleboy/ssh-action@master
with:
host: server.${{ env.SERVER }}.clustercat.com
username: root
key: ${{ secrets.TESTING_SSH_KEY }}
script: |
rm /tmp/branchtest

on-failure:
runs-on: ubuntu-latest
Expand All @@ -52,6 +63,9 @@ jobs:
with:
run_id: ${{ github.event.workflow_run.id}}
if_no_artifact_found: warn
- name: get server name
run: |
echo "SERVER=$(cat ./server/server) >> $GITHUB_ENV"
- name: get PR
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -65,7 +79,7 @@ jobs:
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#990000"
username: "GitHub Bot"
message: " ${{ github.repository}}:${{ github.event.workflow_run.name }}:PR ${{ env.pull_request}} failed: droplets from this workflow (tag ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}) will be deleted in 5 hours"
message: " ${{ github.repository}}:${{ github.event.workflow_run.name }}:PR ${{ env.pull_request}} failed: droplets from this workflow (tag ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}) will be deleted in 3 hours"
file: ./results/results.log
- name: discord error message
uses: appleboy/discord-action@master
Expand All @@ -79,11 +93,21 @@ jobs:
- name: delete droplets
if: success() || failure()
run: |
sleep 5h
sleep 3h
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
TAG: ${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}
- name: mark server as available
if: success() || failure()
uses: appleboy/ssh-action@master
with:
host: server.${{ env.SERVER }}.clustercat.com
username: root
key: ${{ secrets.TESTING_SSH_KEY }}
script: |
rm /tmp/branchtest