-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e97e31
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# This workflow will be triggered on every PR on the main branch | ||
# Note : if the asyncapi file is not present, the job is canceled | ||
|
||
# To get started, configure the following in your repos secrets https://docs.github.com/en/actions/security-guides/encrypted-secrets | ||
# SOLACE_CLOUD_TOKEN: Solace Cloud Token | ||
|
||
name: Config Push Preview | ||
on: | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
EVENT_MESH_NAME: us-central-solace-Prod | ||
PREVIEW_ONLY: TRUE | ||
|
||
jobs: | ||
plan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get asyncapi file in the commit | ||
id: changed_files | ||
uses: tj-actions/changed-files@v40 | ||
with: | ||
files: | | ||
asyncapi* | ||
- name: Read asyncapi content | ||
id: asyncapi | ||
run: | | ||
for file in ${{ steps.changed_files.outputs.all_changed_files }}; do | ||
if [[ ( ${file} == *.yaml ) || ( ${file} == *.yml ) || ( ${file} == *.json ) ]] | ||
then | ||
echo 'asyncFile<<EOF' >> $GITHUB_OUTPUT | ||
echo $(cat $file) >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
fi | ||
done | ||
- name: Extract Application Version ID from asyncapiFile | ||
if: ${{ steps.asyncapi.outputs.asyncFile }} | ||
uses: tmelliottjr/[email protected] | ||
id: epApplicationVersionId | ||
with: | ||
regex: '(?<=x-ep-application-version-id\\": \\")(.*?)(?=\\")' | ||
flags: "gm" | ||
input: ${{steps.asyncapi.outputs.asyncFile}} | ||
|
||
- name: Generate Preview Application Version Deployment Plan | ||
if: ${{ steps.epApplicationVersionId.outputs.resultString }} | ||
id: plan | ||
uses: SolaceDev/[email protected] | ||
with: | ||
SOLACE_CLOUD_TOKEN: ${{ secrets.SOLACE_CLOUD_TOKEN }} | ||
APPLICATION_VERSION_ID: ${{ steps.epApplicationVersionId.outputs.resultString }} | ||
EVENT_MESH_NAME: ${{ env.EVENT_MESH_NAME }} | ||
PREVIEW_ONLY: ${{ env.PREVIEW_ONLY }} | ||
|
||
- name: PR Comment with Deployment Preview | ||
uses: actions/github-script@v6 | ||
if: github.event_name == 'pull_request' | ||
env: | ||
PLAN: "${{ steps.plan.outputs.deployment_plan }}" | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
// 1. Prepare format of the comment | ||
const output = `#### Application Deployment Plan 📖\`${{ steps.plan.outcome }}\` | ||
<details><summary>Show Plan</summary> | ||
|
||
\`\`\`\n | ||
${process.env.PLAN} | ||
\`\`\` | ||
|
||
</details> | ||
|
||
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\` *`; | ||
|
||
// 2. Create PR comment with the deployment plan | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This workflow will be triggered on every merge on the main branch | ||
# Note : if the asyncapi file is not present, the job is canceled | ||
|
||
# To get started, configure the following in your repos secrets https://docs.github.com/en/actions/security-guides/encrypted-secrets | ||
# SOLACE_CLOUD_TOKEN: Solace Cloud Token | ||
|
||
name: Config Push Deploy | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
EVENT_MESH_NAME: us-central-solace-Prod | ||
|
||
jobs: | ||
config-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get asyncapi file in the commit | ||
id: changed_files | ||
uses: tj-actions/changed-files@v40 | ||
with: | ||
files: | | ||
asyncapi* | ||
- name: Read asyncapi content | ||
id: asyncapi | ||
run: | | ||
for file in ${{ steps.changed_files.outputs.all_changed_files }}; do | ||
if [[ ( ${file} == *.yaml ) || ( ${file} == *.yml ) || ( ${file} == *.json ) ]] | ||
then | ||
echo 'asyncFile<<EOF' >> $GITHUB_OUTPUT | ||
echo $(cat $file) >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
fi | ||
done | ||
- name: Extract Application Version ID from asyncapiFile | ||
if: ${{ steps.asyncapi.outputs.asyncFile }} | ||
uses: tmelliottjr/[email protected] | ||
id: epApplicationVersionId | ||
with: | ||
regex: '(?<=x-ep-application-version-id\\": \\")(.*?)(?=\\")' | ||
flags: "gm" | ||
input: ${{steps.asyncapi.outputs.asyncFile}} | ||
|
||
- name: Promote Application Version | ||
if: ${{ steps.epApplicationVersionId.outputs.resultString }} | ||
uses: SolaceDev/[email protected] | ||
with: | ||
SOLACE_CLOUD_TOKEN: ${{ secrets.SOLACE_CLOUD_TOKEN }} | ||
APPLICATION_VERSION_ID: ${{ steps.epApplicationVersionId.outputs.resultString }} | ||
EVENT_MESH_NAME: ${{ env.EVENT_MESH_NAME }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
|
||
# IDE config | ||
.project |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Github Workflow configuration for Spring Cloud Stream with Asyncapi | ||
This repo will have the github workflow needed to plan, provision, and promote a Spring Cloud Stream application using Event Portal, Event Broker, and AsyncaPI | ||
|
||
## Things to note | ||
- This workflow assumes an asyncapi.yml file in the root of the directory. | ||
- Make sure github actions is enabled in your repo | ||
- Settings --> Actions --> General --> Allow all actions and reusable workflows | ||
- Settings --> Actions --> General --> Workflow permissions --> Enable read/write | ||
- Confiure the secrets in your repo as per the [workflow files](.github/workflows) | ||
- Edit this readme to match your project description |