From 5942f1b85b76b8c71acc53e76d75167f9ebb6652 Mon Sep 17 00:00:00 2001 From: Radek Jajko Date: Mon, 23 Aug 2021 12:32:12 +0200 Subject: [PATCH] #1823 Change GHActions workflow settings. 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. --- .github/workflows/build.yml | 7 +- .github/workflows/master.yml | 177 +++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/master.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3ffa4d3ff..7bcf4bcc87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000000..ff891c3feb --- /dev/null +++ b/.github/workflows/master.yml @@ -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 }} \ No newline at end of file