Created
April 1, 2025 10:03
-
-
Save pedes/5c05dad67d8444076e65f1be96b5f8ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: CICD-Mule-CH2.0 | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# Caches dependencies and build outputs to improve workflow execution time. | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- uses: s4u/[email protected] | |
with: | |
servers: | | |
[{ | |
"id": "anypoint-exchange-v3", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "cloudhub-deploy", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "exchange-repository", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
} | |
] | |
# maven build command, could add other flags if needed | |
- name: Build | |
run: mvn -B clean package --file pom.xml | |
# Step to upload the artifact to Exchange | |
exchange: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- uses: s4u/[email protected] | |
with: | |
servers: | | |
[{ | |
"id": "anypoint-exchange-v3", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "cloudhub-deploy", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "exchange-repository", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
} | |
] | |
- name: Publish artifact to Exchange | |
run: | | |
mvn -B clean deploy --file pom.xml | |
# Steps for executing the deployment against Cloudhub2.0 Anypoint Platform | |
deploy: | |
needs: exchange | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- uses: s4u/[email protected] | |
with: | |
servers: | | |
[{ | |
"id": "anypoint-exchange-v3", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "cloudhub-deploy", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
}, | |
{ | |
"id": "exchange-repository", | |
"username": "${{ secrets.ANYPOINT_USERNAME }}", | |
"password": "${{ secrets.ANYPOINT_PASSWORD }}" | |
} | |
] | |
- name: Deploy to CloudHub 2 | |
env: | |
AUTHOR: "Mr Bean" | |
run: | | |
mvn clean deploy --file pom.xml -DmuleDeploy -Denvironment="dev" -Dca_client_id="${{ secrets.CA_CLIENT_ID }}" -Dca_client_secret="${{ secrets.CA_CLIENT_SECRET }}" -DapplicationName="cicd-andres" -Dmessage="mule and cloudhub 2.0 rocks!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment