CI | Engine cyberia | github repository #1011
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
| name: CI | Engine cyberia | github repository | |
| on: | |
| workflow_run: | |
| workflows: ['CI | Publish npm repository package'] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| inputs: | |
| sync: | |
| description: 'Trigger sync-and-deploy CD after build' | |
| required: false | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| message: | |
| description: 'Commit message for the build' | |
| required: false | |
| default: '' | |
| deploy_type: | |
| description: 'CD job type to dispatch (sync-and-deploy or init)' | |
| required: false | |
| default: 'sync-and-deploy' | |
| type: choice | |
| options: | |
| - sync-and-deploy | |
| - init | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| pwa-microservices-template: | |
| if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
| name: Update github repo package Jobs | |
| runs-on: ubuntu-latest | |
| container: | |
| image: quay.io/rockylinux/rockylinux:9 | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install required packages | |
| run: | | |
| dnf install -y sudo tar gzip bzip2 git | |
| dnf install -y curl --allowerasing | |
| - name: Install Node.js | |
| run: | | |
| curl -fsSL https://rpm.nodesource.com/setup_24.x | bash - | |
| dnf install nodejs -y | |
| - name: Install dependencies | |
| run: | | |
| npm install -g underpost | |
| npm install | |
| underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }} | |
| - name: Set git global credentials | |
| run: | | |
| git config --global --add safe.directory '*' | |
| git config --global user.name 'underpostnet' | |
| git config --global user.email 'development@underpost.net' | |
| - name: Build repository | |
| run: | | |
| cd .. && underpost clone underpostnet/pwa-microservices-template | |
| FULL_MSG=$(cd pwa-microservices-template && git log -1 --pretty=%B 2>/dev/null || echo "") | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| if [ -n "${{ github.event.inputs.message }}" ]; then | |
| LAST_COMMIT_MESSAGE="${{ github.event.inputs.message }}" | |
| else | |
| LAST_COMMIT_MESSAGE=$(echo "$FULL_MSG" | sed '1s/^[^:]*: [^ ]* //' | grep -v '^\[cd:' || true) | |
| fi | |
| SHOULD_CD="${{ github.event.inputs.sync }}" | |
| DEPLOY_TYPE="${{ github.event.inputs.deploy_type }}" | |
| else | |
| LAST_COMMIT_MESSAGE=$(echo "$FULL_MSG" | sed '1s/^[^:]*: [^ ]* //' | grep -v '^\[cd:' || true) | |
| CD_MARKER=$(echo "$FULL_MSG" | grep '^\[cd:engine-cyberia:' | head -1 || true) | |
| if [ -n "$CD_MARKER" ]; then | |
| SHOULD_CD="true" | |
| DEPLOY_TYPE=$(echo "$CD_MARKER" | sed 's/\[cd:engine-cyberia:\(.*\)\]/\1/') | |
| else | |
| SHOULD_CD="false" | |
| fi | |
| fi | |
| if [ -z "$LAST_COMMIT_MESSAGE" ]; then | |
| LAST_COMMIT_MESSAGE="Update engine cyberia repository" | |
| fi | |
| echo "[INFO] Captured commit message: $LAST_COMMIT_MESSAGE" | |
| echo "[INFO] Should CD: $SHOULD_CD, Deploy type: $DEPLOY_TYPE" | |
| underpost clone --bare underpostnet/engine-cyberia | |
| cd engine | |
| node bin/build dd-cyberia development | |
| cd ../pwa-microservices-template | |
| rm -rf ./.git | |
| mv ../engine-cyberia.git ./.git | |
| git init | |
| git config user.name 'underpostnet' | |
| git config user.email 'development@underpost.net' | |
| git add . | |
| git commit -m "$LAST_COMMIT_MESSAGE" | |
| underpost push . underpostnet/engine-cyberia | |
| if [ "$SHOULD_CD" = "true" ]; then | |
| if [ -z "$DEPLOY_TYPE" ]; then | |
| DEPLOY_TYPE="sync-and-deploy" | |
| fi | |
| echo "[INFO] Dispatching engine-cyberia CD ${DEPLOY_TYPE}" | |
| curl -s -X POST \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: token ${{ secrets.GIT_AUTH_TOKEN }}" \ | |
| "https://api.github.com/repos/underpostnet/engine/actions/workflows/engine-cyberia.cd.yml/dispatches" \ | |
| -d "{\"ref\":\"master\",\"inputs\":{\"job\":\"${DEPLOY_TYPE}\"}}" | |
| else | |
| echo "[INFO] Deployment skipped" | |
| fi |