Skip to content

Commit

Permalink
NO-ISSUE: Migrated kubesmarts daily/staging/release workflows to serv…
Browse files Browse the repository at this point in the history
…erless-logic-sandbox-deployment
  • Loading branch information
paulovmr committed Dec 13, 2023
1 parent 2979987 commit 50289dd
Show file tree
Hide file tree
Showing 7 changed files with 592 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/daily_dev_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: "Daily dev :: Publish"

on:
schedule:
- cron: "0 4 * * *" # 4am UTC everyday
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/daily_dev_publish.yml"

concurrency:
group: ${{ github.event.pull_request && format('daily-dev-publish-pr-{0}', github.event.pull_request.number) || format('daily-dev-publish-ref-{0}', github.ref_name) }}
cancel-in-progress: true

jobs:
build:
if: github.repository == 'kiegroup/serverless-logic-sandbox-deployment'
runs-on: ubuntu-latest
env:
KIE_TOOLS_BUILD__buildContainerImages: "false"
KIE_TOOLS_BUILD__runLinters: "false"
KIE_TOOLS_BUILD__runTests: "false"
KIE_TOOLS_BUILD__runEndToEndTests: "false"

DASHBUILDER__viewerImageRegistry: "quay.io"
DASHBUILDER__viewerImageAccount: "kie-tools"
DASHBUILDER__viewerImageName: "dashbuilder-viewer-image"
DASHBUILDER__viewerImageBuildTags: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__dashbuilderViewerImageTag: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageName: "serverless-logic-web-tools-swf-builder-image"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageTag: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageBuildTags: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageName: "serverless-logic-web-tools-base-builder-image"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageTag: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageBuildTags: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageName: "serverless-logic-web-tools-swf-dev-mode-image"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageTag: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageBuildTags: "daily-dev"
SERVERLESS_LOGIC_WEB_TOOLS__corsProxyUrl: "https://daily-dev-cors-proxy-kie-sandbox.rhba-0ad6762cc85bcef5745bb684498c2436-0000.us-south.containers.appdomain.cloud"

steps:
- name: "Clone kie-tools"
uses: actions/checkout@v3
with:
path: kie-tools
repository: apache/incubator-kie-tools

# This bash script will set an output version for this step. It can be used with steps.version.outputs.version
- name: "Output version"
id: version
run: |
cd kie-tools
echo "version=$(node -e "console.log(require('./package.json').version);")" >> $GITHUB_OUTPUT
shell: bash

- name: "Cache Maven packages"
if: github.event_name != 'pull_request'
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
with:
path: ~/.m2
key: ${{ runner.os }}-daily-dev-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-daily-dev-m2

- name: "Setup environment"
uses: ./kie-tools/.github/actions/setup-env
with:
working_dir: kie-tools

- name: "Bootstrap"
id: bootstrap
uses: ./kie-tools/.github/actions/bootstrap
with:
working_dir: kie-tools

- name: "Build serverless-logic-web-tools"
env:
WEBPACK__minimize: "true"
WEBPACK__tsLoaderTranspileOnly: "false"
DISPLAY: ":99.0"
SERVERLESS_LOGIC_WEB_TOOLS__buildInfo: "${{ steps.version.outputs.version }} (daily-dev) @ ${{ github.sha }}"
run: |
cd kie-tools
pnpm -F @kie-tools/serverless-logic-web-tools... build:prod
- name: "Checkout serverless-logic-sandbox-deployment"
uses: actions/checkout@v3
with:
token: ${{ github.event_name != 'pull_request' && secrets.KIE_GROUP_TOOLS_TOKEN || secrets.GITHUB_TOKEN }}
path: serverless-logic-sandbox-deployment
repository: kiegroup/serverless-logic-sandbox-deployment
ref: gh-pages

- name: "Update serverless-logic-sandbox-deployment resources"
if: github.event_name != 'pull_request'
run: |
cd serverless-logic-sandbox-deployment
rm -rf dev
mkdir dev
cp -r ../kie-tools/packages/serverless-logic-web-tools/dist/* dev/
git config --global user.email "[email protected]"
git config --global user.name "KIE Group Tools (kie-group-tools)"
today=$(date -I)
git add . && git commit -m "KIE Tools Daily Dev Build resources - $today" || echo "No changes."
git push origin gh-pages
cd -
142 changes: 142 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: "Release :: Build"

on:
workflow_call:
inputs:
dry_run:
type: boolean
required: true
base_ref:
type: string
required: true
tag:
type: string
required: false
default: "0.0.0"
upload_asset_url:
type: string
required: false
default: ""
runners:
type: string
required: false
default: '{"serverless_logic_web_tools":"false"}'
secrets:
kie_group_tools_token:
required: false
gh_token:
required: false

env:
KIE_TOOLS_BUILD__runLinters: "false"
KIE_TOOLS_BUILD__runTests: "false"
KIE_TOOLS_BUILD__runEndToEndTests: "false"
KIE_TOOLS_BUILD__buildContainerImages: "false"

jobs:
extract_runners:
runs-on: ubuntu-latest

outputs:
serverless_logic_web_tools: ${{ steps.set_runners.outputs.serverless_logic_web_tools }}

steps:
- name: "Set Runners"
id: set_runners
shell: bash
run: |
echo "serverless_logic_web_tools=${{ fromJSON(inputs.runners).serverless_logic_web_tools }}" >> $GITHUB_OUTPUT
- name: "Print Runners"
shell: bash
run: |
echo "serverless_logic_web_tools: ${{ steps.set_runners.outputs.serverless_logic_web_tools }}"
serverless_logic_web_tools:
env:
SERVERLESS_LOGIC_WEB_TOOLS__version: "${{ inputs.tag }}"
SERVERLESS_LOGIC_WEB_TOOLS__samplesRepositoryRef: "${{ inputs.tag }}"
SERVERLESS_LOGIC_WEB_TOOLS__buildInfo: ""
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageName: "serverless-logic-web-tools-swf-builder-image"
SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageTag: "${{ inputs.tag }}"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageName: "serverless-logic-web-tools-base-builder-image"
SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageTag: "${{ inputs.tag }}"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageRegistry: "quay.io"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageAccount: "kie-tools"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageName: "serverless-logic-web-tools-swf-dev-mode-image"
SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageTag: "${{ inputs.tag }}"
DASHBUILDER__viewerImageRegistry: "quay.io"
DASHBUILDER__viewerImageAccount: "kie-tools"
DASHBUILDER__viewerImageName: "dashbuilder-viewer-image"
SERVERLESS_LOGIC_WEB_TOOLS__dashbuilderViewerImageTag: "${{ inputs.tag }}"
SERVERLESS_LOGIC_WEB_TOOLS__corsProxyUrl: "https://cors-proxy-kie-sandbox.rhba-0ad6762cc85bcef5745bb684498c2436-0000.us-south.containers.appdomain.cloud"

if: ${{ always() && needs.extract_runners.outputs.serverless_logic_web_tools == 'true' }}
runs-on: ubuntu-latest
needs: [extract_runners]
steps:
- name: "Checkout kie-tools"
uses: actions/checkout@v3
with:
path: kie-tools
repository: apache/incubator-kie-tools

- name: "Checkout @ Simulated squashed-merge if PR"
uses: ./kie-tools/.github/actions/checkout-pr
with:
ref: ${{ inputs.base_ref }}
path: kie-tools

- name: "Checkout serverless-logic-sandbox-deployment"
if: ${{ !inputs.dry_run }}
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/serverless-logic-sandbox-deployment
fetch-depth: 0
token: ${{ secrets.kie_group_tools_token }}
repository: kiegroup/serverless-logic-sandbox-deployment
ref: gh-pages

- name: "Cache Maven packages"
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
with:
path: ~/.m2
key: ${{ runner.os }}-serverless-logic-web-tools-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-serverless-logic-web-tools-m2

- name: "Setup environment"
id: setup_env
uses: ./kie-tools/.github/actions/setup-env
with:
working_dir: kie-tools

- name: "Bootstrap"
id: bootstrap
uses: ./kie-tools/.github/actions/bootstrap
with:
working_dir: kie-tools
pnpm_filter_string: -F @kie-tools/serverless-logic-web-tools...

- name: "Build"
working-directory: ${{ github.workspace }}/kie-tools
run: |
pnpm ${{ steps.bootstrap.outputs.pnpm_filter_string }} build:prod
- name: "Deploy to GitHub Pages (serverless-logic-sandbox-deployment)"
if: ${{ !inputs.dry_run }}
working-directory: ${{ github.workspace }}/serverless-logic-sandbox-deployment
shell: bash
run: |
echo "Reset deployment dir"
shopt -s extglob
rm -rf -- !("dev"|"staging"|".nojekyll"|"CNAME"|"0.25.0"|"schemas")
echo "Copy resources"
cp -r ${{ github.workspace }}/kie-tools/packages/serverless-logic-web-tools/dist/* .
echo "Commit changes and push"
git add .
git commit -m "Deploy ${{ inputs.tag }}"
git push origin gh-pages
23 changes: 23 additions & 0 deletions .github/workflows/release_dry_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Release :: Dry Run"

on:
workflow_dispatch:
schedule:
- cron: "0 6 * * *" # 6am UTC everyday
pull_request:
branches: ["**"]
paths:
- ".github/workflows/release*"

concurrency:
group: ${{ github.event.pull_request && format('release-dry-run-pr-{0}', github.event.pull_request.number) || format('release-dry-run-ref-{0}', github.ref_name) }}
cancel-in-progress: true

jobs:
dry_run:
if: github.repository == 'kiegroup/serverless-logic-sandbox-deployment'
uses: ./.github/workflows/release_build.yml
with:
dry_run: true
base_ref: ${{ github.event.pull_request && github.base_ref || github.ref }}
runners: '{"serverless_logic_web_tools":"true"}'
64 changes: 64 additions & 0 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Release :: Publish"

on:
workflow_dispatch:
inputs:
tag:
type: string
required: true
description: "Tag associated with the release"
runners:
type: string
required: true
description: "Jobs to run (JSON)"
default: '{"serverless_logic_web_tools":"true"}'

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
upload_asset_url: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).upload_url }}
release_ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }}
steps:
- name: "Fetch release for ${{ github.event.inputs.tag }}"
uses: octokit/[email protected]
id: fetch_release_for_tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: GET /repos/{repo}/releases/tags/{tag}
repo: ${{ github.repository }}
tag: ${{ github.event.inputs.tag }}

- name: "Checkout kie-tools"
uses: actions/checkout@v3
with:
path: kie-tools
repository: apache/incubator-kie-tools
ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }}

- name: "Check `tag` against `(package.json).version`"
shell: bash
run: |
cd kie-tools
[ "${{ github.event.inputs.tag }}" == "$(node -p "require('./package.json').version")" ]
cd -
- name: "Checkout serverless-logic-sandbox-deployment"
uses: actions/checkout@v3
with:
path: serverless-logic-sandbox-deployment
repository: kiegroup/serverless-logic-sandbox-deployment

build_and_publish:
needs: [prepare]
uses: ./.github/workflows/release_build.yml
with:
dry_run: false
base_ref: ${{ needs.prepare.outputs.release_ref }}
tag: ${{ github.event.inputs.tag }}
upload_asset_url: ${{ needs.prepare.outputs.upload_asset_url }}
runners: ${{ github.event.inputs.runners }}
secrets:
kie_group_tools_token: ${{ secrets.KIE_GROUP_TOOLS_TOKEN }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 50289dd

Please sign in to comment.