Skip to content

LSP Hourly Check and Update #4096

LSP Hourly Check and Update

LSP Hourly Check and Update #4096

# Hourly application version check and update workflow
name: LSP Hourly Check and Update
on:
schedule:
- cron: "0 * * * *"
workflow_dispatch:
inputs:
branch:
description: "Branch to run against"
required: false
default: "snapshot"
type: string
node-version:
description: 'Node.js version to use'
required: false
default: '20.x'
type: string
jobs:
check-and-update:
runs-on: ubuntu-latest
# environment: your-environment-name # Uncomment and set your environment name to use environment variables
steps:
- name: Record start time
id: start-time
run: echo "start=$(date +%s)" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || 'snapshot' }}
fetch-depth: 0 # Fetch all history to ensure we get the latest
- name: Ensure latest commit
run: |
git fetch origin ${{ inputs.branch || 'snapshot' }}
git reset --hard origin/${{ inputs.branch || 'snapshot' }}
- name: Get checked out commit SHA
id: checkout-sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Setup Git Configuration
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Make scripts executable
run: chmod +x scripts/check-apps.sh scripts/check-core.sh
- name: Check Eureka Components Versions
id: check-core
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
echo "Running Eureka components version check..."
set +e
./scripts/check-core.sh 2>&1 | tee /tmp/check-core-output.log
exit_code=${PIPESTATUS[0]}
set -e
echo "SCRIPT_EXIT_CODE=${exit_code}" >> $GITHUB_OUTPUT
exit $exit_code
- name: Check and Update Application Versions
id: check-apps
env:
FAR_URL: ${{ vars.FAR_URL }}
run: |
echo "Running application version check..."
# Capture output and exit code
set +e # Don't exit on error
./scripts/check-apps.sh 2>&1 | tee /tmp/check-apps-output.log
exit_code=${PIPESTATUS[0]} # Get exit code of the script, not tee
set -e # Re-enable exit on error
# Store the exit code for later use
echo "SCRIPT_EXIT_CODE=${exit_code}" >> $GITHUB_OUTPUT
# Exit with the original code to fail the step if script failed
exit $exit_code
- name: Install Node ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
check-latest: true
always-auth: true
- name: Build stripes
id: build-stripes
run: |
set +e
{
rm -f yarn.lock
yarn install
{
echo "## Yarn Dependencies"
echo '```'
yarn list --pattern @folio
echo '```'
} >> $GITHUB_STEP_SUMMARY
current_branch=$(git branch --show-current)
git add yarn.lock
git commit -m "[CI] Update yarn.lock" || echo "No changes to commit"
git push origin $current_branch
} 2>&1 | tee /tmp/build-stripes-output.log
exit_code=${PIPESTATUS[0]}
set -e
echo "SCRIPT_EXIT_CODE=${exit_code}" >> $GITHUB_OUTPUT
exit $exit_code
- name: Capture error details
if: always()
id: error-details
run: |
if [ "${{ steps.check-apps.outputs.SCRIPT_EXIT_CODE }}" != "0" ]; then
echo "FAILED_STEP=Check and Update Application Versions" >> $GITHUB_OUTPUT
if [ -f /tmp/check-apps-output.log ]; then
ERROR_DETAILS=$(tail -n 10 /tmp/check-apps-output.log | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
echo "ERROR_DETAILS=${ERROR_DETAILS}" >> $GITHUB_OUTPUT
else
echo "ERROR_DETAILS=No error log available" >> $GITHUB_OUTPUT
fi
elif [ "${{ steps.build-stripes.outputs.SCRIPT_EXIT_CODE }}" != "0" ]; then
echo "FAILED_STEP=Build stripes" >> $GITHUB_OUTPUT
if [ -f /tmp/build-stripes-output.log ]; then
ERROR_DETAILS=$(tail -n 20 /tmp/build-stripes-output.log | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
echo "ERROR_DETAILS=${ERROR_DETAILS}" >> $GITHUB_OUTPUT
else
echo "ERROR_DETAILS=No error log available" >> $GITHUB_OUTPUT
fi
else
echo "FAILED_STEP=" >> $GITHUB_OUTPUT
echo "ERROR_DETAILS=" >> $GITHUB_OUTPUT
fi
- name: Detect if updates were made
if: success()
id: updates-check
run: |
if grep -q "Successfully updated" /tmp/check-apps-output.log 2>/dev/null; then
echo "UPDATES_MADE=true" >> $GITHUB_OUTPUT
else
echo "UPDATES_MADE=false" >> $GITHUB_OUTPUT
fi
- name: Get final commit SHA
if: success()
id: final-sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Notify on Failure
if: failure()
uses: slackapi/slack-github-action@v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.EUREKA_CI_SLACK_BOT_TOKEN }}
errors: true
payload: |
channel: "${{ vars.GENERAL_SLACK_NOTIF_CHANNEL }}"
text: "🚨 LSP Hourly Check and Update FAILED"
blocks:
- type: section
text:
type: mrkdwn
text: "*🚨 LSP Hourly Check and Update FAILED <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|#${{ github.run_number }}>*"
- type: section
fields:
- type: mrkdwn
text: "*Branch:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>"
- type: mrkdwn
text: "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
- type: mrkdwn
text: "*Failed Step:*\n${{ steps.error-details.outputs.FAILED_STEP || 'Unknown step' }}"
- type: mrkdwn
text: "*Triggered by:*\n${{ github.event_name == 'schedule' && 'Scheduled (cron)' || github.actor }}"
- type: section
text:
type: mrkdwn
text: "*Error Details:*\n```${{ steps.error-details.outputs.ERROR_DETAILS || 'No error details available' }}```"
attachments:
- color: "danger"
footer: "Eureka CI/CD • ${{ github.workflow }}"
- name: Calculate duration
if: success()
id: duration
run: |
end_time=$(date +%s)
start_time=${{ steps.start-time.outputs.start }}
duration=$((end_time - start_time))
minutes=$((duration / 60))
seconds=$((duration % 60))
if [ $minutes -gt 0 ]; then
echo "duration=${minutes}m ${seconds}s" >> $GITHUB_OUTPUT
else
echo "duration=${seconds}s" >> $GITHUB_OUTPUT
fi
- name: Notify on Success
if: success() && steps.updates-check.outputs.UPDATES_MADE == 'true'
uses: slackapi/slack-github-action@v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.EUREKA_CI_SLACK_BOT_TOKEN }}
errors: true
payload: |
channel: "${{ vars.GENERAL_SLACK_NOTIF_CHANNEL }}"
text: "✅ LSP Hourly Check and Update SUCCESS"
blocks:
- type: section
text:
type: mrkdwn
text: "*✅ LSP Hourly Check and Update SUCCESS <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|#${{ github.run_number }}>*"
- type: section
fields:
- type: mrkdwn
text: "*Triggered from:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>"
- type: mrkdwn
text: "*Checked out:*\n<${{ github.server_url }}/${{ github.repository }}/tree/${{ inputs.branch || 'snapshot' }}|${{ inputs.branch || 'snapshot' }}>"
- type: mrkdwn
text: "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ steps.final-sha.outputs.sha }}|${{ steps.final-sha.outputs.sha }}>"
- type: mrkdwn
text: "*Duration:*\n${{ steps.duration.outputs.duration }}"
- type: mrkdwn
text: "*Triggered by:*\n${{ github.event_name == 'schedule' && 'Scheduled (cron)' || github.actor }}"
attachments:
- color: "good"
footer: "Eureka CI/CD • ${{ github.workflow }}"