Skip to content

Daily EarnApp Version Check #75

Daily EarnApp Version Check

Daily EarnApp Version Check #75

Workflow file for this run

name: Daily EarnApp Version Check
on:
schedule:
- cron: '0 3 * * *' # daily at 03:00 UTC
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Extract EarnApp version
id: version
run: |
wget -qO /tmp/install.sh https://cdn-earnapp.b-cdn.net/static/earnapp/install.sh
VERSION=$(grep '^VERSION=' /tmp/install.sh | cut -d'"' -f2)
if [ -z "$VERSION" ]; then
echo "❌ Failed to extract EarnApp version!"
exit 1
fi
echo "Found version: $VERSION"
echo "version=v$VERSION" >> $GITHUB_OUTPUT
- name: Check if version already exists in registry
id: check
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Checking if version $VERSION already exists in registry..."
if docker manifest inspect ghcr.io/xterna/earnapp:$VERSION > /dev/null 2>&1; then
echo "✅ Version $VERSION already exists in registry"
echo "should_build=false" >> $GITHUB_OUTPUT
else
echo "🆕 Version $VERSION is NEW - triggering build workflow"
echo "should_build=true" >> $GITHUB_OUTPUT
fi
- name: Trigger build workflow
if: steps.check.outputs.should_build == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const version = '${{ steps.version.outputs.version }}';
console.log(`Triggering build workflow for version ${version}`);
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-image.yml',
ref: 'main',
inputs: {
version: version
}
});
- name: Summary
run: |
VERSION="${{ steps.version.outputs.version }}"
if [ "${{ steps.check.outputs.should_build }}" == "true" ]; then
echo "### 🚀 Build Triggered" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version **$VERSION** is new and build workflow has been triggered." >> $GITHUB_STEP_SUMMARY
else
echo "### ⏭️ Build Skipped" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version **$VERSION** already exists in registry. No build needed." >> $GITHUB_STEP_SUMMARY
fi