Skip to content

Merge pull request #101 from layer5io/update-org-id #1935

Merge pull request #101 from layer5io/update-org-id

Merge pull request #101 from layer5io/update-org-id #1935

name: Build and push to remote
on:
workflow_dispatch:
inputs:
orgId:
description: 'Organization ID (see https://cloud.layer5.io/identity/organizations for ID)'
required: false
type: string
version:
description: 'Module version (default: latest)'
required: false
default: 'latest'
type: string
academy-name:
description: 'The name of the Academy being updated (e.g., Layer5 Academy)'
required: false
default: 'Academy'
type: string
push:
branches:
- master
paths-ignore:
- '.github/**'
- README.md
jobs:
build-artifacts:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: 'master'
- name: Setup Hugo (Extended)
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.147.9'
extended: true
- name: Conditionally update Hugo module based on orgId
if: ${{ github.event.inputs.orgId != '' }}
run: |
ORG_ID="${{ github.event.inputs.orgId }}"
VERSION="${{ github.event.inputs.version || 'latest' }}"
MODULE=$(jq -r --arg orgId "$ORG_ID" '.orgToModuleMapping[$orgId].module' academy_config.json)
if [ "$MODULE" = "null" ] || [ -z "$MODULE" ]; then
echo "❌ Module not found for orgId: $ORG_ID"
exit 1
fi
echo "✅ Found module for orgId '$ORG_ID': $MODULE"
# Set environment variables for later steps
echo "ACADEMY_NAME=${MODULE##*/}" >> $GITHUB_ENV
echo "NOTES=Updated from academy-build workflow" >> $GITHUB_ENV
make update-module module="$MODULE" version="$VERSION"
make update-org-to-module-version orgId="$ORG_ID" version="$VERSION"
- name: Set default environment variables
if: ${{ github.event.inputs.orgId == '' }}
run: |
echo "ACADEMY_NAME=Layer5 Academy" >> $GITHUB_ENV
echo "NOTES=Manual build from academy-build workflow" >> $GITHUB_ENV
- name: Ensure environment variables are set
run: |
# Set defaults if variables are not already set
echo "ACADEMY_NAME=${ACADEMY_NAME:-Layer5 Academy}" >> $GITHUB_ENV
echo "NOTES=${NOTES:-Build from academy-build workflow}" >> $GITHUB_ENV
- name: Install dependencies
run: make setup
- name: Build Academy
run: make prod-build
- name: Pull changes from self master
run: git pull origin master
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Build Academy
commit_options: '--signoff'
branch: master
commit_user_name: l5io
commit_user_email: l5io@layer5.io
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
- name: Checkout meshery-cloud repo
uses: actions/checkout@v5
with:
repository: layer5io/meshery-cloud
token: ${{ secrets.GH_ACCESS_TOKEN }}
path: meshery-cloud
ref: master
- name: Copy build output to /academy
run: |
rm -rf meshery-cloud/academy
mkdir -p meshery-cloud/academy
rsync -av --delete public/ meshery-cloud/academy/
cp academy_config.json meshery-cloud/academy/
# - name: Commit & push academy to meshery-cloud
# uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_message: "[Academy] Content update for orgId: ${{ github.event.inputs.orgId || 'manual' }}"
# commit_options: '--signoff'
# repository: meshery-cloud
# branch: academy/content-update
# file_pattern: academy
# commit_user_name: l5io
# commit_user_email: l5io@layer5.io
# env:
# GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Create PR in meshery-cloud for release-drafter integration
if: github.event.inputs.version != ''
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
path: meshery-cloud
commit-message: "[Academy] Academy content update v${{ github.event.inputs.version }}"
# committer: l5io
signoff: true
title: "${{ inputs.academy-name || github.event.inputs.academy-name }} ${{ github.event.inputs.version }} content update"
body: "Automated PR for ${{ inputs.academy-name || github.event.inputs.academy-name }} ${{ github.event.inputs.version }} (organization: ${{ github.event.inputs.orgId || 'manual' }})."
# branch: academy-${{ github.event.inputs.version }}-${{ github.run_number }}
labels: academy
delete-branch: true
- name: Enable auto-merge for PR in meshery-cloud repo
if: github.event.inputs.version != '' && steps.cpr.outputs.pull-request-number != ''
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: merge
repository: layer5io/meshery-cloud