From 9f057263ced31ee69cbd5084f91a870f6a8d554b Mon Sep 17 00:00:00 2001 From: Oleh Astappiev Date: Fri, 6 Oct 2023 10:43:39 +0200 Subject: [PATCH] ci: add deploy to staging --- .github/workflows/ci.yml | 37 ++++++---------- .github/workflows/deploy.yml | 39 ++++++++++++++++ .gitlab-ci.yml | 86 ------------------------------------ pom.xml | 19 +------- 4 files changed, 55 insertions(+), 126 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffe01f828..8b4fb94b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,8 @@ -name: test +name: CI on: push: - branches: - - main - -env: - MVN: mvn --show-version --batch-mode --quiet - GITHUB_TOKEN: ${{ secrets.GH_PAT }} + pull_request: jobs: styles: @@ -22,8 +17,11 @@ jobs: - run: npm run lint:scss --silent - run: npm run lint:js --silent - lint: + java: runs-on: ubuntu-latest + env: + MVN: mvn --batch-mode + GITHUB_TOKEN: ${{ secrets.GH_PAT }} steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v3 @@ -32,19 +30,12 @@ jobs: distribution: 'temurin' cache: 'maven' server-id: github-l3s-learnweb - - run: $MVN checkstyle:check - - run: $MVN compile spotbugs:check - test: - runs-on: ubuntu-latest - needs: - - lint - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - cache: 'maven' - server-id: github-l3s-learnweb - - run: $MVN test + - name: checkstyle + run: $MVN checkstyle:check + + - name: spotbugs + run: $MVN compile spotbugs:check + + - name: test + run: $MVN --show-version test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..2e818d8f5 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Deploy + +on: + workflow_run: + workflows: [ CI ] + types: [ completed ] + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + server-id: github-l3s-learnweb + + - run: mvn --quiet -P prod,!local -Dmaven.test.skip=true install + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + + - uses: actions/upload-artifact@v3 + with: + name: learnweb-war + path: target/Learnweb.war + + deploy-dev: + runs-on: ubuntu-latest + needs: [ build ] + steps: + - uses: actions/download-artifact@v3 + with: + name: learnweb-war + + - run: ls -l -R diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 8b0410ed2..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,86 +0,0 @@ -variables: - MAVEN_OPTS: "-DproxySet=true -Dhttp.proxyHost=web-proxy.rrzn.uni-hannover.de -Dhttp.proxyPort=3128 -Dhttp.nonProxyHosts=*.uni-hannover.de -Dhttps.proxyHost=web-proxy.rrzn.uni-hannover.de -Dhttps.proxyPort=3128" - MAVEN_CLI_OPTS: "-P prod,!local --batch-mode" - MAVEN_CLI_QUIET: "--quiet -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.MavenCli=OFF" - -stages: - - lint - - test - - build - - deploy - -# Check for code style issues -lint: - stage: lint - tags: - - javascript - - java - script: - - npm ci - - npm run lint --silent - - mvn $MAVEN_CLI_OPTS $MAVEN_CLI_QUIET checkstyle:check - cache: - paths: - - node_modules/ - -# Run Java tests -test: - stage: test - tags: - - java - script: - - mvn $MAVEN_CLI_OPTS $MAVEN_CLI_QUIET compile spotbugs:check - - mvn $MAVEN_CLI_OPTS test - rules: - - if: '$CI_COMMIT_BRANCH != "master"' - -# Build Java sources (includes tests) -build: - stage: build - tags: - - javascript - - java - script: - - npm run build - - mvn $MAVEN_CLI_OPTS $MAVEN_CLI_QUIET spotbugs:check - - mvn $MAVEN_CLI_OPTS install - rules: - - if: '$CI_COMMIT_BRANCH == "master"' - cache: - paths: - - node_modules/ - - target/Learnweb.war - -# Any commit to `master` branch will be deployed to /dev instance -deploy_dev: - stage: deploy - tags: - - java - script: - - mvn $MAVEN_CLI_OPTS tomcat7:redeploy-only -Dpath=dev - environment: - name: dev - url: https://learnweb.l3s.uni-hannover.de/dev/ - rules: - - if: '$CI_COMMIT_BRANCH == "master"' - cache: - paths: - - target/Learnweb.war - policy: pull - -# A commit to `master` brunch with message `chore: version release` will be deployed to ROOT instance -deploy_prod: - stage: deploy - tags: - - java - script: - - mvn $MAVEN_CLI_OPTS tomcat7:deploy-only -Dpath=ROOT - environment: - name: prod - url: https://learnweb.l3s.uni-hannover.de/ - rules: - - if: '$CI_COMMIT_BRANCH == "master" && $CI_COMMIT_TITLE == "chore: version release"' - cache: - paths: - - target/Learnweb.war - policy: pull diff --git a/pom.xml b/pom.xml index 77322dc34..56331439a 100644 --- a/pom.xml +++ b/pom.xml @@ -475,21 +475,6 @@ - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - http://learnweb.l3s.uni-hannover.de:8100/manager/text - - ${env.LEARNWEB_TOMCAT_USERNAME} - - ${env.LEARNWEB_TOMCAT_PASSWORD} - - /${path}##${project.version} - - org.eclipse.jetty @@ -553,7 +538,7 @@ - [3.6,) + [3.8,) [17,) @@ -584,7 +569,7 @@ - + prod