Skip to content

Commit

Permalink
#1823 Change GHActions workflow settings.
Browse files Browse the repository at this point in the history
Separate GHActions workflow to 2 different tasks. One will be responsible for building the stable version of Scada-LTS and the second one will be producing the docker image with PR code merged. As it was before.
  • Loading branch information
radek2s committed Aug 23, 2021
1 parent 3b1eb58 commit 5942f1b
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 6 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: Simple Scada-LTS workflow
name: Scada-LTS PR development workflow
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- 'master'
tags:
- 'v*'
jobs:

compile:
Expand Down
177 changes: 177 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Scada-LTS build stable version workflow
on:
push:
branches:
- 'master'
- 'develop'
- 'release/[0-9].[0-9]+.[0-9]+'
tags:
- 'v*'
release:
types: [published]
jobs:

compile:
name: Compile and Test Scada-LTS application
runs-on: ubuntu-latest
env:
CATALINA_HOME: /home/runner/tomcat/apache-tomcat-9.0.52
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache Tomcat
uses: actions/cache@v2
with:
key: ${{ runner.os }}-tomcat-${{ github.run_id }}
path: /home/runner/tomcat
restore-keys: |
${{ runner.os }}-tomcat-
- name: Install Tomcat
run: mkdir -p /home/runner/tomcat; cd /home/runner/tomcat; wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.52/bin/apache-tomcat-9.0.52.tar.gz; tar xvzf apache-tomcat-9.0.52.tar.gz
- name: Show Tomcat
run: ls $CATALINA_HOME
- name: Test JUnit Scada Application
run: gradle test
- name: Build Scada-LTS WAR Application
run: gradle -PskipUi=true compileJava
- name: Cache Scada-LTS application
uses: actions/cache@v2
with:
key: ${{ runner.os }}-slts-${{ github.run_id }}
path: ./build/

buildui:
name: Test and Build Scada-LTS new User Interface
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Cache node modules
id: nodeCache
uses: actions/cache@v2
with:
path: ./scadalts-ui/node_modules
key: ${{ runner.os }}-node-${{ github.run_id }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ github.run_id }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.nodeCache.outputs.cache-hit != 'true'
working-directory: ./scadalts-ui
run: npm install
- name: Run Frontend UnitTests
working-directory: ./scadalts-ui
run: npm run-script test:unit
- name: Get Scada-LTS latest release version
id: relver
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: SCADA-LTS
repo: Scada-LTS
- name: Prepare Application Vairables
working-directory: ./scadalts-ui
run: npm run-script build-config -- ${{ steps.relver.outputs.release }} $GITHUB_RUN_ID $GITHUB_HEAD_REF $GITHUB_SHA $GITHUB_ACTOR $GITHUB_BASE_REF
- name: Build User Interface
working-directory: ./scadalts-ui
run: npm run-script build
- name: Cache Frontend
uses: actions/cache@v2
with:
key: ${{ runner.os }}-frontend-${{ github.run_id }}
path: ./scadalts-ui/dist

war:
name: Build WAR archive
needs: [compile, buildui]
runs-on: ubuntu-latest
env:
CATALINA_HOME: /home/runner/tomcat/apache-tomcat-9.0.52
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
- name: Load Cached node modules
uses: actions/cache@v2
with:
path: ./scadalts-ui/node_modules
key: ${{ runner.os }}-node-${{ github.run_id }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ github.run_id }}-${{ hashFiles('**/package-lock.json') }}
- name: Load Cached Scada-LTS application
uses: actions/cache@v2
with:
key: ${{ runner.os }}-slts-${{ github.run_id }}
path: ./build/
- name: Load Cached Frontend
uses: actions/cache@v2
with:
key: ${{ runner.os }}-frontend-${{ github.run_id }}
path: ./scadalts-ui/dist
- name: Install static web-dependencies
working-directory: ./WebContent/resources
run: npm install
- name: Build Scada Application
run: gradle -PskipUi=true war
- name: Save WAR file to cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-war-${{ github.run_id }}
path: ./build/libs/Scada-LTS.war

deploy-artefact:
name: Deploy Scada-LTS as Artifact
needs: [war]
runs-on: ubuntu-latest
steps:
- name: Load WAR file to cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-war-${{ github.run_id }}
path: ./build/libs/Scada-LTS.war
- name: Deploy WAR artifact
uses: actions/upload-artifact@v2
with:
name: Scada-LTS
path: ./build/libs/Scada-LTS.war

deploy-docker:
name: Deploy Scada-LTS as Docker Image
needs: [ war ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load WAR file to cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-war-${{ github.run_id }}
path: ./build/libs/Scada-LTS.war
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: scadalts/scadalts
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 5942f1b

Please sign in to comment.