Skip to content

Commit aa6d509

Browse files
authored
Add GH Actions Workflow for publishing new releases to BAR infra (#1918)
1 parent a936b1e commit aa6d509

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/bar-cdn-publish.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Workflow for Beyond All Reaon, it only motifies BAR infra that a new engine
2+
# release was published.
3+
name: Publish Engine to BAR CDN
4+
on:
5+
release:
6+
types: [published]
7+
workflow_dispatch:
8+
inputs:
9+
releaseId:
10+
description: Release Id as returned from GitHub Releases API
11+
required: true
12+
jobs:
13+
push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
id-token: write
17+
steps:
18+
- uses: google-github-actions/auth@v2
19+
id: auth
20+
with:
21+
project_id: 'bar-springfiles-syncer'
22+
workload_identity_provider: 'projects/741013749543/locations/global/workloadIdentityPools/github-actions/providers/github'
23+
create_credentials_file: false
24+
- uses: actions/github-script@v7
25+
env:
26+
ACCESS_TOKEN: ${{ steps.auth.outputs.auth_token }}
27+
with:
28+
script: |
29+
const rel = await github.rest.repos.getRelease({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
release_id: context.payload.release.id ?? context.payload.inputs.releaseId
33+
});
34+
const engines = rel.data.assets
35+
.filter((a) => a.name.endsWith('64-minimal-portable.7z'))
36+
.map((a) => a.browser_download_url)
37+
.sort();
38+
if (engines.length != 2 || !/linux/.test(engines[0]) || !/windows/.test(engines[1])) {
39+
throw new Error("Not found engine archives!");
40+
}
41+
42+
const msg = JSON.stringify({
43+
category: "engine",
44+
linux64: { url: engines[0] },
45+
windows64: { url: engines[1] },
46+
});
47+
const resp = await fetch("https://pubsub.googleapis.com/v1/projects/bar-springfiles-syncer/topics/cache-requests:publish", {
48+
method: 'POST',
49+
body: JSON.stringify({messages: [{ attributes: { "requestType": "SyncRequest"}, data: btoa(msg) }]}),
50+
headers: {
51+
"Content-Type": "application/json",
52+
"Authorization": `Bearer ${process.env.ACCESS_TOKEN}`
53+
}
54+
});
55+
if (!resp.ok) {
56+
throw new Error(`Failed to push message: ${resp.statusText}`);
57+
}

0 commit comments

Comments
 (0)