Update versions #11
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: Update versions | |
| # Refresh the SDK versions shown on the product family pages from the canonical feed | |
| # https://products.groupdocs.com/versions.json. Upstream regenerates that file twice a day | |
| # (06:00 + 18:00 UTC via its own GitHub Action), so we run +10 minutes later. | |
| # | |
| # update_versions.py trims the feed to just the fields we render (version + release-notes URL) and | |
| # sorts keys, so data/versions.json only changes when a version actually moves (not on the upstream's | |
| # generatedAt/downloads churn). We commit the data file to BOTH branches (keeping main == production) | |
| # and redeploy a target environment ONLY when its branch's data file changed. | |
| on: | |
| schedule: | |
| - cron: '10 6,18 * * *' # 06:10 + 18:10 UTC (+10 min after upstream publishes versions.json) | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: Environment to redeploy | |
| type: choice | |
| options: [production, staging] | |
| default: production | |
| force: | |
| description: Deploy even if versions did not change | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: update-versions | |
| cancel-in-progress: false | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.sync.outputs.changed }} | |
| environment: ${{ steps.env.outputs.environment }} | |
| ref: ${{ steps.env.outputs.ref }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: production | |
| fetch-depth: 0 | |
| - name: Resolve target environment + branch | |
| id: env | |
| run: | | |
| ENV="${{ github.event.inputs.environment || 'production' }}" | |
| if [ "$ENV" = "staging" ]; then REF=main; else REF=production; fi | |
| echo "environment=$ENV" >> "$GITHUB_OUTPUT" | |
| echo "ref=$REF" >> "$GITHUB_OUTPUT" | |
| - name: Fetch + transform versions.json | |
| run: python3 update_versions.py --out /tmp/versions.json | |
| - name: Commit data/versions.json on both branches (deploy only if the target branch changed) | |
| id: sync | |
| env: | |
| FORCE: ${{ github.event.inputs.force || 'false' }} | |
| TARGET_REF: ${{ steps.env.outputs.ref }} | |
| run: | | |
| git config user.name "groupdocs-version-bot" | |
| git config user.email "groupdocs-version-bot@users.noreply.github.com" | |
| git fetch origin production main | |
| changed=false | |
| for BR in production main; do | |
| git checkout -B "$BR" "origin/$BR" | |
| cp /tmp/versions.json data/versions.json | |
| if git diff --quiet -- data/versions.json; then | |
| echo "[$BR] no version changes" | |
| else | |
| git add data/versions.json | |
| git commit -m "Update SDK versions from products.groupdocs.com/versions.json" | |
| git push origin "$BR" | |
| echo "[$BR] versions updated" | |
| if [ "$BR" = "$TARGET_REF" ]; then changed=true; fi | |
| fi | |
| done | |
| if [ "$FORCE" = "true" ]; then changed=true; fi | |
| echo "changed=$changed" >> "$GITHUB_OUTPUT" | |
| echo "Deploy target ($TARGET_REF) changed: $changed" | |
| # Rebuild + redeploy the product family pages with the new versions. Only the 15 product builds | |
| # render versions (home/aggregates don't), so we skip them. Builds the target branch HEAD (the | |
| # commit the sync job just pushed) via deploy_product's `ref` input. | |
| deploy: | |
| needs: sync | |
| if: needs.sync.outputs.changed == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| product_family: | |
| - annotation | |
| - assembly | |
| - classification | |
| - comparison | |
| - conversion | |
| - editor | |
| - markdown | |
| - merger | |
| - metadata | |
| - parser | |
| - redaction | |
| - search | |
| - signature | |
| - viewer | |
| - watermark | |
| uses: ./.github/workflows/deploy_product.yml | |
| with: | |
| product_family: ${{ matrix.product_family }} | |
| environment: ${{ needs.sync.outputs.environment }} | |
| ref: ${{ needs.sync.outputs.ref }} | |
| secrets: inherit |