Skip to content

Commit

Permalink
Add refresh EC2 deployment action
Browse files Browse the repository at this point in the history
Includes a github action for refreshing the EC2 deployment through SSH
and checking the public instance status after the deployment is
complete.
  • Loading branch information
Sergiu Miclea authored and claudiubelu committed Jul 27, 2022
1 parent 6b8049b commit 0b271dd
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/refresh_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Refresh EC2 FINOS Waltz deployment

on:
workflow_dispatch:
schedule:
# Runs everyday at 00:00. (see https://crontab.guru)
- cron: "0 0 * * *"

jobs:
build:
name: Trigger Juju refresh on EC2 Deployment
runs-on: ubuntu-latest
steps:
- name: Refresh Deployment
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
set -x
# Running juju status will show us the current revisions of the charms.
juju status --relations
juju refresh finos-waltz --channel edge
juju refresh waltz-ingress --channel stable
# Running juju status will show us the current revisions of the charms.
juju status --relations
- name: Check Waltz Public Instance status
run: |
wait_for_curl() {
url="$1"
for i in {1..30}; do
status=$(curl -s -o /dev/null -w "%{http_code}" "$url")
if [ "$status" = "200" ]; then
break
fi
if [ "$i" -eq 30 ]; then
echo "Failed to get 200 response status from $url. Got status $status."
exit 1
fi
sleep 10
done
}
wait_for_curl "http://demo.waltz.finos.org/"
echo "Waltz is reachable"
19 changes: 19 additions & 0 deletions docs/periodic_job.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# FINOS Waltz Juju EC2 deployment - Periodic refresh

The [Refresh EC2 FINOS Waltz deployment](../.github/workflows/refresh_deployment.yaml) job will run periodically for a configured Juju EC2 deployment and will refresh the Waltz and Ingress charms to their latest revision. This job requires a few Secrets to be defined in the project repository (`Settings > Secrets > Actions > Repository secrets` or using the `gh secret set` command):

- `SSH_USER`: The username to use when connecting to the EC2 instance.
- `SSH_HOST`: The hostname of the EC2 instance.
- `SSH_KEY`: The private SSH key to use when connecting to the EC2 instance.

Once the above repository secrets have been set, the job should succeed. A manual job can also be triggered by going to `Actions > Refresh EC2 FINOS Waltz deployment > Run workflow`.

The Github CLI commands for setting the secrets are:

```bash
gh -R finos/waltz-integration-juju secret set SSH_USER
gh -R finos/waltz-integration-juju secret set SSH_HOST
gh -R finos/waltz-integration-juju secret set SSH_KEY < ~/.ssh/id_rsa
```

The CLI will prompt you to paste the `SSH_USER` and `SSH_HOST` secrets in the terminal, while `SSH_KEY` will load the private key from the specified location.

0 comments on commit 0b271dd

Please sign in to comment.