Update update-topics.yaml

This commit is contained in:
Michael Telatynski 2023-07-13 12:21:41 +01:00 committed by GitHub
parent 231d3387e6
commit 9856863b03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,9 +21,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: Matrix environment: Matrix
steps: steps:
- id: stable
uses: fangqiuming/latest-release-version@3225574bda429695112385003694f43c51f93635 # forked
- uses: actions/github-script@v6 - uses: actions/github-script@v6
env: env:
HS_URL: ${{ secrets.BETABOT_HS_URL }} HS_URL: ${{ secrets.BETABOT_HS_URL }}
@ -31,10 +28,18 @@ jobs:
PUBLIC_ROOM_ID: "!YTvKGNlinIzlkMTVRl:matrix.org" PUBLIC_ROOM_ID: "!YTvKGNlinIzlkMTVRl:matrix.org"
ANNOUNCEMENT_ROOM_ID: "!bijaLdadorKgNGtHdA:matrix.org" ANNOUNCEMENT_ROOM_ID: "!bijaLdadorKgNGtHdA:matrix.org"
TOKEN: ${{ secrets.BETABOT_ACCESS_TOKEN }} TOKEN: ${{ secrets.BETABOT_ACCESS_TOKEN }}
RELEASE_TOPIC: "Stable: ${{ steps.stable.outputs.tag_name }} | Release status: ${{ inputs.expected_status }} expected ${{ inputs.expected_date }}" RELEASE_STATUS: "Release status: ${{ inputs.expected_status }} expected ${{ inputs.expected_date }}"
with: with:
script: | script: |
const { HS_URL, TOKEN, RELEASE_TOPIC, LOBBY_ROOM_ID, PUBLIC_ROOM_ID, ANNOUNCEMENT_ROOM_ID } = process.env; const { HS_URL, TOKEN, RELEASE_STATUS, LOBBY_ROOM_ID, PUBLIC_ROOM_ID, ANNOUNCEMENT_ROOM_ID } = process.env;
const repo = context.repo;
const { data } = await octokit.rest.repos.getLatestRelease({
owner: repo.owner,
repo: repo.repo,
});
const releaseTopic = `Stable: ${{ data.tag_name }} | ${RELEASE_STATUS}`;
const regex = /Stable: v(\d+.\d+.\d+) \| Release status: (\w+) expected (\w+ \d+\w+)/gm; const regex = /Stable: v(\d+.\d+.\d+) \| Release status: (\w+) expected (\w+ \d+\w+)/gm;
@ -56,14 +61,14 @@ jobs:
}); });
const data = await res.json(); const data = await res.json();
const topic = data.topic.replace(regex, RELEASE_TOPIC); const topic = data.topic.replace(regex, releaseTopic);
if (topic === data.topic) { if (topic === data.topic) {
console.log(roomId, "nothing to do"); console.log(roomId, "nothing to do");
return; return;
} }
if (data["org.matrix.msc3765.topic"]) { if (data["org.matrix.msc3765.topic"]) {
data["org.matrix.msc3765.topic"].forEach(d => { data["org.matrix.msc3765.topic"].forEach(d => {
d.body = d.body.replace(regex, RELEASE_TOPIC); d.body = d.body.replace(regex, releaseTopic);
}); });
} }