-
Notifications
You must be signed in to change notification settings - Fork 22
126 lines (110 loc) · 4.89 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on: [push, pull_request]
jobs:
matrix_prep:
# Using a separate job and agent so as to be able to use tools like 'sed' and 'jq'
runs-on: ubuntu-22.04
# Defining outputs of a job allows for easier consumption and use
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
# Checking out code as the set-matrix step utilizes a file named matrix_includes.json
- name: Check out code
uses: actions/[email protected]
# This step is explained more in a following section
- id: set-matrix
run: |
matrix=$(jq . .github/workflows/matrix_includes.json)
echo "matrix={\"include\":$(echo $matrix)}\"" >> $GITHUB_OUTPUT
build:
needs: matrix_prep
runs-on: ubuntu-22.04
strategy:
# We need to convert the json string output into an object that the GitHub Workflow expects.
# Thankfully, the json-schema for Workflows allows 'matrix' to be set to an expression.
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
steps:
- name: Environment
run: |
echo GITHUB_WORKSPACE $GITHUB_WORKSPACE
echo GITHUB_REF $GITHUB_REF
echo GITHUB_SHA $GITHUB_SHA
echo GITHUB_EVENT_NAME $GITHUB_EVENT_NAME
echo JAVA ${{ matrix.java }}
echo PROFILE ${{ matrix.profile }}
echo TYCHO ${{ matrix.tycho }}
- name: Check if update site is needed
id: updatesite_check
env:
PROFILE: ${{ matrix.profile }}
run: |
if [[ "$PROFILE" == *"updatesites"* ]]; then export UPDATE_SITES=true; fi
echo "UPDATE_SITES=${UPDATE_SITES}"
echo "UPDATE_SITES=${UPDATE_SITES}" >> $GITHUB_OUTPUT
- name: Check out code
uses: actions/[email protected]
- name: Set up JDK ${{ matrix.java }}
uses: actions/[email protected]
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- uses: actions/[email protected]
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.product') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.product') }}
- name: Setup website (documentation)
if: ${{ steps.updatesite_check.outputs.UPDATE_SITES }}
run: |
chmod a+x ./scripts/website-install.sh
./scripts/website-install.sh
- name: Create directory for website (documentation)
run: |
mkdir plugins/org.obeonetwork.m2doc.doc/doc
- name: Build website (documentation)
if: ${{ steps.updatesite_check.outputs.UPDATE_SITES }}
run: |
export TAG="nightly"
if [[ "$(echo $GITHUB_REF | cut -d"/" -f2)" != "heads" ]]; then export TAG="$(echo $GITHUB_REF | cut -d"/" -f3)"; fi
echo TAG $TAG
chmod a+x ./scripts/website-build.sh
./scripts/website-build.sh $TAG
- name: Install metacity and xvfb
uses: awalsh128/[email protected]
with:
packages: xvfb metacity
version: cache-apt-pkgs-${{ matrix.profile }}
- name: Build with Maven (${{ matrix.profile }})
env:
MAVEN_OPTS: ${{ matrix.mavenOpt }}
run: |
/usr/bin/Xvfb :99 -ac -screen 0 1440x900x16&
ps auxwww | grep Xvfb
export DISPLAY=:99
echo DISPLAY $DISPLAY
mvn clean verify -fae -P${{ matrix.profile }} "-Dtycho=${{ matrix.tycho }}" -Dmaven.wagon.provider.http=httpclient -Dmaven.artifact.threads=12 -Dhttp.tcp.nodelay=false
- name: Prepare deploy local directory
id: prepare_deploy
if: ${{ steps.updatesite_check.outputs.UPDATE_SITES && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
run: |
export TAG_OR_BRANCH="$(echo $GITHUB_REF | cut -d"/" -f3)/nightly"
if [[ "$(echo $GITHUB_REF | cut -d"/" -f2)" != "heads" ]]; then export TAG_OR_BRANCH="$(echo $GITHUB_REF | cut -d"/" -f3)"; fi
chmod a+x ./scripts/prepare-deploy-local-dir.sh
./scripts/prepare-deploy-local-dir.sh $GITHUB_WORKSPACE/$TAG_OR_BRANCH
echo "TAG_OR_BRANCH=${TAG_OR_BRANCH}"
echo "TAG_OR_BRANCH=${TAG_OR_BRANCH}" >> $GITHUB_OUTPUT
- name: Deploy to S3
if: ${{ steps.updatesite_check.outputs.UPDATE_SITES && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
SOURCE_DIR: ${{ steps.prepare_deploy.outputs.TAG_OR_BRANCH }}
DEST_DIR: ${{ steps.prepare_deploy.outputs.TAG_OR_BRANCH }}