-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (99 loc) · 4.26 KB
/
Copy pathworkflow-java.yaml
File metadata and controls
101 lines (99 loc) · 4.26 KB
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
name: Java Workflow
# Standard workflow for any Java based projects built with Jib. Because the current RCSB Java applications are tightly coupled, production image release must be separately scheduled and deployed in tandem with other Java applications.
on:
workflow_call:
inputs:
mainline_branch:
type: string
default: "master"
description: "The mainline branch for the repo. Deployments to the staging and production environments are done only on push to this branch. Defaults to the master branch."
docker_namespace:
type: string
default: "rcsb"
description: "The Docker image namespace built by jib. Defaults to 'rcsb'."
do_production_build:
type: string
default: "true"
description: "Build and push a production tagged container image for this application on commits to the mainline_branch."
# TODO remove once we are out of OpenStack and build-locker artifacts are not needed anymore
distribution:
description: "buildlocker distribution name. Must be provided if 'type' is set to [war|jar]"
type: string
required: false
type:
description: 'buildlocker distribution type [war|jar]. Use any other value to skip pushing to build-locker'
default: "skip"
type: string
required: false
jobs:
debug:
name: "Debug conditionals"
runs-on:
- "self-hosted"
- "java"
steps:
- name: "Output inputs and refs"
run: |
echo "=== Check branch conditionals"
echo "github.ref_name: ${{ github.ref_name }}"
echo "inputs.mainline_branch: ${{ inputs.mainline_branch }}"
echo "Is github.ref_name == inputs.mainline_branch: ${{ github.ref_name == inputs.mainline_branch }}"
echo "=== Check event conditionals"
echo "github.event_name: ${{ github.event_name }}"
echo "Is github.event_name != 'pull_request': ${{ github.event_name != 'pull_request' }}"
echo "=== Check environment conditionals"
echo "inputs.do_production_build: ${{ inputs.do_production_build }}"
# Test projects
test_mvn:
# If we are in a commit from the [actions] pipeline (see java-roll-version-and-release.yaml), do nothing
if: |
!contains(github.event.head_commit.message, '[actions]')
name: "Run tests via mvn"
uses: ./.github/workflows/run_mvn.yaml
with:
script: "test --no-transfer-progress"
publish_surefire_test_report: true
build_mvn:
# If we are in a commit from the [actions] pipeline (see java-roll-version-and-release.yaml), do nothing
if: |
!contains(github.event.head_commit.message, '[actions]')
name: "Build project with mvn"
uses: ./.github/workflows/run_mvn.yaml
with:
script: package
# Push image tagged with branch name
build_jib:
name: "Build and push branch-tagged docker image with Jib"
# We skip if not in mainline branch: that's because there will always be a production image built for the mainline branch case below. This is useful for other branches
if: |
github.event_name != 'pull_request' &&
github.ref_name != inputs.mainline_branch
needs:
- test_mvn
- build_mvn
runs-on:
- "self-hosted"
- "java"
steps:
- uses: actions/checkout@v4
- name: "Push to Harbor with branch name as tag (replacing disallowed '/' by '-')"
run: |
SAFE_BRANCH="${{ github.ref_name }}"
SAFE_BRANCH="${SAFE_BRANCH//\//-}"
echo "We will use tag ${SAFE_BRANCH} for pushing to Harbor. Original git branch name was ${{ github.ref_name }}"
mvn package jib:build -Djib.to.tags=${SAFE_BRANCH} -Djib.target.namespace=rcsb --no-transfer-progress -Dmaven.test.skip=true -Djib.httpTimeout=0
# Production jobs
# The production build is taken care within this job as part of rolling version in commits
roll_version:
if: |
inputs.do_production_build == 'true' &&
github.ref_name == inputs.mainline_branch &&
github.event_name != 'pull_request'
name: "Roll maven version and release production"
needs:
- test_mvn
- build_mvn
uses: ./.github/workflows/java-roll-version-and-release.yaml
with:
distribution: ${{ inputs.distribution }}
type: ${{ inputs.type }}