Skip to content

Commit

Permalink
Add GH action to build app and create a release (#9)
Browse files Browse the repository at this point in the history
* Update publish_app.yml

Temporarily disable tag filtering

* Update publish_app.yml

Debug build step

* Add missing npm clean install step

* Fix eslint warnings in HxtleakEventLog.js so GH action will run

* Fix upload artifact step to use path relative to workspace

* Add archive creation and tag release

* Add zip archive creation to release

* Rename release workflow and merge jobs

* Fix paths to release artifacts

* Set build output and artifact creation to build/app for cleaner deployment path

* Update deploy plays to use tagged release of package and install app from release artefacts
  • Loading branch information
timcnicholls authored May 10, 2023
1 parent 991aef3 commit 825049b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 38 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/publish_app.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/release_app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release_app
run-name: Build static app and publish with a release
on:
push:
tags:
- '*'

jobs:

release:

runs-on: ubuntu-latest

defaults:
run:
working-directory: control/app

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Clean install app
run: npm ci
- name: Build app
run: npm run build
- name: Create TGZ archive
run: |
cd build
tar -cvzf app_build.tgz app
- name: Create ZIP archive
run: |
cd build
zip -r app_build.zip app
- name: List built files
run: ls -lR build
- name: Create release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
control/app/build/app_build.tgz
control/app/build/app_build.zip
1 change: 1 addition & 0 deletions control/app/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_ENDPOINT_URL=
BUILD_PATH=build/app
5 changes: 1 addition & 4 deletions control/app/src/components/HxtleakEventLog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { useState, useEffect, useCallback, useRef } from 'react';

import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';

import StatusCard from './StatusCard';

const HxtleakEventLog = ({ endpoint }) => {
Expand Down Expand Up @@ -35,7 +32,7 @@ const HxtleakEventLog = ({ endpoint }) => {
console.log(error.message);
})

}, [events_since, last_timestamp, events]);
}, [events_since, last_timestamp, events]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
let timer_id = null;
Expand Down
11 changes: 10 additions & 1 deletion deploy/ansible/deploy_hxtleak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,22 @@

- name: Install hxtleak package into virtualenv
ansible.builtin.pip:
name: "git+{{ hxtleak_repo_url }}#egg=hxtleak&subdirectory=control"
name: "git+{{ hxtleak_repo_url }}.git@{{ hxtleak_release }}#egg=hxtleak&subdirectory=control"
virtualenv: "{{ hxt_install_dir}}"
editable: yes
become: yes
become_user: "{{ hxt_user }}"
tags: app

- name: Install hxtleak app from Github release
ansible.builtin.unarchive:
src: "{{ hxtleak_repo_url }}/releases/download/{{ hxtleak_release }}/app_build.tgz"
dest: "{{ hxt_install_dir}}"
remote_src: yes
owner: "{{ hxt_user }}"
group: "{{ hxt_group }}"
tags: app

- name: Create config directory for odin-control
ansible.builtin.file:
path: "{{ hxt_install_dir }}/config"
Expand Down
3 changes: 2 additions & 1 deletion deploy/ansible/group_vars/hxtleak_bbb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ hxt_group: hexitec
hxt_user: hexiuser
hxt_sw_dir: /hxt_sw
hxt_install_dir: "{{ hxt_sw_dir }}/install"
hxtleak_repo_url: https://github.com/stfc-aeg/hxtleak.git
hxtleak_repo_url: https://github.com/stfc-aeg/hxtleak
hxtleak_release: "0.1.1"
2 changes: 1 addition & 1 deletion deploy/ansible/templates/hxtleak.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
debug_mode = 1
http_port = 80
http_addr = 0.0.0.0
static_path = {{ hxt_install_dir }}/static
static_path = {{ hxt_install_dir }}/app
adapters = hxtleak
enable_cors = true

Expand Down

0 comments on commit 825049b

Please sign in to comment.