Skip to content

Commit

Permalink
Zeitgeist Client Update Automation (#944)
Browse files Browse the repository at this point in the history
* Add client-auto-update.yml (#924)

* Add scripts/ansible/client-auto-update-playbook.yml (#924)

* Include step to update image version of existing network spec in OnFinality (#924)

* Include logic if  non-existent (#924)

* Change backup Zeitgeist_parachain binary

Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>

* Trigger workflow based on tags (#924)

Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>

* Trigger workflow based on tags (#924)

Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>

* Add workflow steps to update Zeitgeist and battery_station image (#924)

Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>

* Modify client-auto-update-playbook.yml (#924)

* Update v0.3.4 to v0.3.9

---------

Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>
  • Loading branch information
samuelarogbonlo and sea212 committed Jul 20, 2023
1 parent ea97e10 commit dedb812
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/client-auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy
on:
# Triggers this Action on push or pull request events on the "main" branch and when manually requested from the "Actions" tab
workflow_dispatch:
push:
tags:
- '^v[0-9]+.[0-9]+.[0-9]+$'

jobs:
auto-update-client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repository
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Run Ansible playbook
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
uses: dawidd6/action-ansible-playbook@v2.6.1
with:
playbook: scripts/ansible/client-auto-update.yml
directory: ./
key: ${{ secrets.ANSIBLE_SSH_PRIVATE_KEY }}
inventory: ${{ secrets.ANSIBLE_INVENTORY }}

35 changes: 29 additions & 6 deletions .github/workflows/docker-hub-parachain.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: Publish features parachain to Docker Hub

on:
push:
tags:
- '*'
workflow_dispatch:
push:
tags:
- '^v[0-9]+.[0-9]+.[0-9]+$'

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v2
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Docker meta
id: meta
Expand All @@ -38,12 +40,33 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3.2.0
with:
build-args: |
PROFILE=production
FEATURES=parachain
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


- name: Update image version of the existing Zeitgeist network spec
uses: "OnFinality-io/action-onf-release@v1"
with:
onf-access-key: ${{ secrets.ONF_ACCESS_KEY }}
onf-secret-key: ${{ secrets.ONF_SECRET_KEY }}
onf-workspace-id: ${{ secrets.ONF_WORKSPACE_ID }}
onf-network-key: ${{ secrets.ONF_NETWORK_KEY_ZG }}
onf-sub-command: image
onf-action: add
image-version: ${{ steps.vars.outputs.tag }}

- name: Update image version of the existing Battery Station network spec
uses: "OnFinality-io/action-onf-release@v1"
with:
onf-access-key: ${{ secrets.ONF_ACCESS_KEY }}
onf-secret-key: ${{ secrets.ONF_SECRET_KEY }}
onf-workspace-id: ${{ secrets.ONF_WORKSPACE_ID }}
onf-network-key: ${{ secrets.ONF_NETWORK_KEY_BS }}
onf-sub-command: image
onf-action: add
image-version: ${{ steps.vars.outputs.tag }}
71 changes: 71 additions & 0 deletions scripts/ansible/client-auto-update-playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
- hosts: zeitgeist
gather_facts: no
become: true
environment:
RELEASE_VERSION: "{{ lookup('env', 'RELEASE_VERSION') }}"

tasks:
- name: Get Zeitgeist services
no_log: true
shell: ls -a /etc/systemd/system/zeitgeist* | xargs -n 1 basename
register: zeitgeist_files

- name: Stop Zeitgeist services
no_log: true
systemd:
name: "{{ item }}"
state: stopped
with_items: "{{ zeitgeist_files.stdout_lines }}"

- name: Check if Mount Dir Exists
no_log: true
stat:
path: /mnt/
register: mnt

- name: Remove Previous Zeitgeist Client in Mount Dir
no_log: true
shell: |
cd /mnt/*/services/zeitgeist/bin
rm zeitgeist
when: mnt.stat.exists and mnt.stat.isdir

- name: Remove Previous Zeitgeist Client
no_log: true
shell: |
cd /services/zeitgeist/bin
rm zeitgeist
when: not mnt.stat.exists and mnt.stat.isdir

- name: Download Zeitgeist Client to Mount Dir
no_log: true
shell: |
cd /mnt/*/services/zeitgeist/bin
if [[ -v RELEASE_VERSION ]]; then
wget -O zeitgeist https://github.com/zeitgeistpm/zeitgeist/releases/download/$RELEASE_VERSION/zeitgeist_parachain
else
wget -O zeitgeist https://github.com/zeitgeistpm/zeitgeist/releases/download/v0.3.9/zeitgeist_parachain
fi
chmod 0755 zeitgeist
chown zeitgeist:zeitgeist zeitgeist
when: mnt.stat.exists and mnt.stat.isdir

- name: Download Zeitgeist Client
no_log: true
shell: |
cd /services/zeitgeist/bin
if [[ -v RELEASE_VERSION ]]; then
wget -O zeitgeist https://github.com/zeitgeistpm/zeitgeist/releases/download/$RELEASE_VERSION/zeitgeist_parachain
else
wget -O zeitgeist https://github.com/zeitgeistpm/zeitgeist/releases/download/v0.3.9/zeitgeist_parachain
fi
chmod 0755 zeitgeist
chown zeitgeist:zeitgeist zeitgeist
when: not mnt.stat.exists and mnt.stat.isdir

- name: Start Zeitgeist Services
no_log: true
systemd:
name: "{{ item }}"
state: started
with_items: "{{ zeitgeist_files.stdout_lines }}"

0 comments on commit dedb812

Please sign in to comment.