-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (137 loc) · 4.97 KB
/
Copy pathupdate_versions.yml
File metadata and controls
146 lines (137 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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.
#
# scripts/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
# then redeploy BOTH environments automatically — production (from `production`) and staging (from `main`) —
# each only when its own branch's data file actually changed.
on:
schedule:
- cron: '10 6,18 * * *' # 06:10 + 18:10 UTC (+10 min after upstream publishes versions.json)
workflow_dispatch:
inputs:
force:
description: Redeploy even if versions did not change
type: boolean
default: false
environment:
description: When forcing, which environment(s) to redeploy
type: choice
options: [both, production, staging]
default: both
permissions:
contents: write
concurrency:
group: update-versions
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
outputs:
prod_changed: ${{ steps.sync.outputs.prod_changed }}
staging_changed: ${{ steps.sync.outputs.staging_changed }}
steps:
- uses: actions/checkout@v4
with:
ref: production
fetch-depth: 0
- name: Fetch + transform versions.json
run: python3 scripts/update_versions.py --out /tmp/versions.json
- name: Commit data/versions.json on both branches (flag each branch that changed)
id: sync
env:
FORCE: ${{ github.event.inputs.force || 'false' }}
FORCE_ENV: ${{ github.event.inputs.environment || 'both' }}
run: |
git config user.name "groupdocs-version-bot"
git config user.email "groupdocs-version-bot@users.noreply.github.com"
git fetch origin production main
prod_changed=false
staging_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" = "production" ]; then prod_changed=true; else staging_changed=true; fi
fi
done
# Manual dispatch with force: redeploy the selected environment(s) even with no data change.
if [ "$FORCE" = "true" ]; then
case "$FORCE_ENV" in
production) prod_changed=true ;;
staging) staging_changed=true ;;
*) prod_changed=true; staging_changed=true ;;
esac
fi
echo "prod_changed=$prod_changed" >> "$GITHUB_OUTPUT"
echo "staging_changed=$staging_changed" >> "$GITHUB_OUTPUT"
echo "prod_changed=$prod_changed staging_changed=$staging_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. Each environment builds its own branch
# HEAD (the commit the sync job just pushed) via deploy_product's `ref` input, and runs only when
# that branch's data/versions.json actually changed.
deploy_production:
needs: sync
if: needs.sync.outputs.prod_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: production
ref: production
secrets: inherit
deploy_staging:
needs: sync
if: needs.sync.outputs.staging_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: staging
ref: main
secrets: inherit