Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danijeldragicevic committed Sep 5, 2024
0 parents commit 05925bc
Show file tree
Hide file tree
Showing 24 changed files with 960 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/actions/deploy-to-ch1-config/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Deploy to Cloud Hub 1.0'

inputs:
username:
required: true
password:
required: true
targetEnvironment:
required: true

runs:
using: "composite"
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-
- uses: actions/download-artifact@v4
with:
name: artifacts

- name: Deploy the application
run: |
artifactName=$(ls *.jar | head -1)
echo "Artifact Name: $artifactName"
mvn deploy -DmuleDeploy -DskipMunitTests -PcloudHubDeployment\
-Dmule.artifact=$artifactName \
-Danypoint.username="$username" \
-Danypoint.password="$password" \
-Danypoint.environment="$targetEnvironment"
shell: bash
env:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
targetEnvironment: ${{ inputs.targetEnvironment }}
51 changes: 51 additions & 0 deletions .github/actions/deploy-to-ch2-config/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Deploy to Cloud Hub 2.0'

inputs:
username:
required: true
password:
required: true
targetEnvironment:
required: true

runs:
using: "composite"
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-
- uses: actions/download-artifact@v4
with:
name: artifacts

- name: Publish to Exchange
run: |
mvn deploy --settings .maven/settings.xml -DskipMunitTests \
-Danypoint.username="$username" \
-Danypoint.password="$password" \
shell: bash
env:
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Deploy the application
run: |
artifactName=$(ls *.jar | head -1)
mvn deploy --settings .maven/settings.xml -DmuleDeploy -DskipMunitTests -Pcloudhub2Deployment\
-Dmule.artifact=$artifactName \
-Danypoint.username="$username" \
-Danypoint.password="$password" \
-Danypoint.environment="$targetEnvironment"
shell: bash
env:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
targetEnvironment: ${{ inputs.targetEnvironment }}
24 changes: 24 additions & 0 deletions .github/actions/deployment-type-config/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Set deployment type'

inputs:
targetEnvironment:
required: true

runs:
using: "composite"
steps:
- name: Set deployment type
run: |
if [[ "$targetEnvironment" == "dev" || "$targetEnvironment" == "qa" ]]; then
echo "deploymentType=cloudHubDeployment" >> $GITHUB_ENV
elif [[ "$targetEnvironment" == "prod" ]]; then
echo "deploymentType=cloudhub2Deployment" >> $GITHUB_ENV
else
echo "Skipping deployment"
exit 0
fi
shell: bash
env:
targetEnvironment: ${{ inputs.targetEnvironment }}
139 changes: 139 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.tooling-project

# ------------------------------------------------------------------------------ #
# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
# ------------------------------------------------------------------------------ #
*.class

# Package Files #
*.jar
*.war
*.ear

# ------------------------------------------------------------------------------------------- #
# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
# ------------------------------------------------------------------------------------------- #
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.classpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# --------------- #
# Studio-specific #
# --------------- #
target/
.mule/
.DS_Store
velocity.log
10 changes: 10 additions & 0 deletions .maven/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
<server>
<id>Repository</id>
<username>${anypoint.username}</username>
<password>${anypoint.password}</password>
</server>
</servers>
</settings>
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "mule-xml-debugger",
"request": "launch",
"name": "Debug Mule Application",
"mule.project": "${workspaceFolder}",
"mule.runtime.args": "${config:mule.runtime.defaultArguments}"
}
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.apivcs": true,
"**/.gitignore": true,
"**/.designer.json": true,
"**/.exchange.xml": true,
"**/.vscode": true,
"**/.mvn": true,
"**/.tmp": true,
"**/.settings": true,
"**/.exchange_modules_tmp": true,
"target": true,
".mule": true
}
}
Loading

0 comments on commit 05925bc

Please sign in to comment.