-
Notifications
You must be signed in to change notification settings - Fork 23
73 lines (63 loc) · 2.29 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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# 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:
branches: [ master ]
pull_request:
branches: [ master ]
create:
tags:
- '*'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Environment
id: build-env
run: |
echo GITHUB_WORKSPACE $GITHUB_WORKSPACE
echo GITHUB_REF $GITHUB_REF
echo GITHUB_SHA $GITHUB_SHA
echo GITHUB_EVENT_NAME $GITHUB_EVENT_NAME
if [[ "$(echo $GITHUB_REF | cut -d"/" -f2)" != "heads" ]]; then export TAG="$(echo $GITHUB_REF | cut -d"/" -f3)"; export UPDATE_SITE_DIR=$(echo $GITHUB_WORKSPACE/$TAG);fi
echo TAG $TAG
echo UPDATE_SITE_DIR $UPDATE_SITE_DIR
echo ::set-output name=TAG::${TAG}
echo ::set-output name=UPDATE_SITE_DIR::${UPDATE_SITE_DIR}
- name: Checkout
uses: actions/checkout@v2
- name: Set up Java SDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn clean verify
- name: Prepare deploy local directory
id: prepare_deploy
if: ${{ steps.build-env.outputs.TAG != '' }}
run: |
chmod a+x ./prepare-deploy-local-dir.sh
./prepare-deploy-local-dir.sh ${{ steps.build-env.outputs.UPDATE_SITE_DIR }}
- name: Deploy to S3
if: ${{ steps.build-env.outputs.TAG != '' }}
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read
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.build-env.outputs.UPDATE_SITE_DIR }}
DEST_DIR: ${{ steps.build-env.outputs.TAG }}