-
Notifications
You must be signed in to change notification settings - Fork 41
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
Zeitgeist Client Update Automation #944
Changes from all commits
35c6a29
92e5797
ad99403
10f2e2d
c94ab27
b2f83df
c21fae5
ca943a5
4fe0e69
6c55af9
cc78611
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/[email protected] | ||
with: | ||
playbook: scripts/ansible/client-auto-update.yml | ||
directory: ./ | ||
key: ${{ secrets.ANSIBLE_SSH_PRIVATE_KEY }} | ||
inventory: ${{ secrets.ANSIBLE_INVENTORY }} | ||
|
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 | ||
Chralt98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only works as long as there are not two folder trees of the following form: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes for now there's no more than one sub-directory in the /mnt/ directory. These sub-directories contain the parachain and relay-chain data mounted in volumes for each zeitgeist node. |
||
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 }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we set
RELEASE_VERSION
? In the environment variables? What happens, if it is not set? Can we print the RELEASE_VERSION in the Github Actions Debug Console?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
RELEASE_VERSION
is automatically set by the Githubclient-auto-update.yml
workflow as an environment variable. So when the playbook is ran in, it looks for environment variable already set by the Github workflow. I may have to include some logic so the workflow can run ifRELEASE_VERSION
is not specified, just to be on the safer side.