forked from oomol-lab/open-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (94 loc) · 3.55 KB
/
Copy pathdeploy-upstream-release.yml
File metadata and controls
106 lines (94 loc) · 3.55 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
name: Sync latest upstream release to main
on:
schedule:
- cron: "2 20 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: open-connector-release-sync
cancel-in-progress: false
env:
D1_DATABASE_ID: 3919bbda-4559-4f97-a755-7e1f8b330577
R2_BUCKET_NAME: open-connector-transit-files
INITIAL_RELEASE: v1.0.3
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check out this production branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve the latest stable upstream release
id: release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="$(gh api repos/oomol-lab/open-connector/releases/latest --jq '.tag_name')"
case "$tag" in
v*) ;;
*) echo "Unexpected upstream release tag: $tag" >&2; exit 1 ;;
esac
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Check whether this release is already tracked
id: state
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.release.outputs.tag }}
run: |
if [ "$TAG" = "$INITIAL_RELEASE" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "The currently deployed Worker is newer than the initial tracked release $TAG."
elif gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/open-connector-synced-$TAG" >/dev/null 2>&1; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "$TAG is already synced to main."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Fetch the immutable upstream release
if: steps.state.outputs.skip != 'true'
env:
TAG: ${{ steps.release.outputs.tag }}
run: |
cp .github/workflows/deploy-upstream-release.yml "$RUNNER_TEMP/deploy-upstream-release.yml"
git remote add upstream https://github.com/oomol-lab/open-connector.git
git fetch --depth=1 upstream "refs/tags/$TAG:refs/tags/$TAG"
git read-tree --reset -u "$TAG"
- name: Set up Node.js
if: steps.state.outputs.skip != 'true'
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
- name: Validate the upstream release
if: steps.state.outputs.skip != 'true'
run: |
npm ci
npm run lint
npm run format
npm run build
npm test
- name: Prepare Worker assets and production configuration
if: steps.state.outputs.skip != 'true'
run: |
npm run generate:catalog
npm run build:web
node scripts/copy-catalog-assets.ts
cp wrangler.example.jsonc wrangler.jsonc
sed -i "s/<your-d1-database-id>/$D1_DATABASE_ID/" wrangler.jsonc
sed -i "s/<your-bucket-name>/$R2_BUCKET_NAME/" wrangler.jsonc
mkdir -p .github/workflows
cp "$RUNNER_TEMP/deploy-upstream-release.yml" .github/workflows/deploy-upstream-release.yml
- name: Update main and record the synced release
if: steps.state.outputs.skip != 'true'
env:
TAG: ${{ steps.release.outputs.tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: sync upstream release $TAG"
git tag -a "open-connector-synced-$TAG" -m "Synced upstream release $TAG"
git push origin HEAD:main
git push origin "open-connector-synced-$TAG"