-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (116 loc) · 4.46 KB
/
main.yaml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Build and Deploy to Anypoint Platform
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
type: choice
required: true
options:
- dev
- qa
- prod
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '11'
- name: Create release
if: ${{ github.event.inputs.environment == 'qa' }}
run: |
mvn versions:set -DremoveSnapshot versions:commit
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add pom.xml
git commit -m "Create release $version"
git push https://x-access-token:$githubToken@github.com/${{ github.repository }}.git develop
git tag $version
git push https://x-access-token:$githubToken@github.com/${{ github.repository }}.git $version
shell: bash
env:
githubToken: ${{ secrets.G_TOKEN }}
- name: Build with Maven
run: mvn -B package --file pom.xml -DskipMunitTests
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: artifacts
path: target/*.jar
deploy:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Set deployment type
uses: ./.github/actions/deployment-type-config
with:
targetEnvironment: ${{ github.event.inputs.environment }}
- name: Deploy to CH1.0
if: env.deploymentType == 'cloudHubDeployment'
uses: ./.github/actions/deploy-to-ch1-config
with:
username: ${{ secrets.ANYPOINT_PLATFORM_USERNAME }}
password: ${{ secrets.ANYPOINT_PLATFORM_PASSWORD }}
targetEnvironment: ${{ github.event.inputs.environment }}
- name: Deploy to CH2.0
if: env.deploymentType == 'cloudhub2Deployment'
uses: ./.github/actions/deploy-to-ch2-config
with:
username: ${{ secrets.ANYPOINT_PLATFORM_USERNAME }}
password: ${{ secrets.ANYPOINT_PLATFORM_PASSWORD }}
targetEnvironment: ${{ github.event.inputs.environment }}
verify:
needs: deploy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Verify deployment
run: |
if [[ "$targetEnvironment" == "dev" ]]; then
curl -f http://mule-github-actions-app-dev.us-e2.cloudhub.io/api/ping || exit 1
elif [[ "$targetEnvironment" == "qa" ]]; then
curl -f http://mule-github-actions-app-qa.us-e2.cloudhub.io/api/ping || exit 1
elif [[ "$targetEnvironment" == "prod" ]]; then
curl -f https://mule-github-actions-app-prod-qefjd6.5sc6y6-1.usa-e2.cloudhub.io/api/ping || exit 1
else
echo "Skipping deployment verification"
exit 0
fi
shell: bash
env:
targetEnvironment: ${{ github.event.inputs.environment }}
- name: Set next development cycle
if: ${{ github.event.inputs.environment == 'prod' }}
run: |
mvn versions:set -DnextSnapshot versions:commit
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout develop || git checkout -b develop
git add pom.xml
git commit -m "Increase version to $version for next development cycle"
git push https://x-access-token:$githubToken@github.com/${{ github.repository }}.git develop
shell: bash
env:
githubToken: ${{ secrets.G_TOKEN }}