forked from realtyem/synapse-workers
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·57 lines (51 loc) · 2.62 KB
/
Copy pathcheck_for_new_release.yml
File metadata and controls
executable file
·57 lines (51 loc) · 2.62 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
# Found at https://stackoverflow.com/questions/58465057/trigger-a-github-actions-when-another-repository-creates-a-release
# and modified for our purposes. Simple premise: fetch release and prerelease information from github api url's, parse
# into variables and check against committed files to verify the current build version numbers. If any changes, commit
# new version files which will then fire off the docker build workflow. The magic which allows this to happen is in the
# REPO_SCOPED_TOKEN which literally is a github token with full 'repo' scope privileges.
name: Get latest release version
on:
schedule:
# Set time to run to 18:00, which is I think UTC time? About 5 hours ahead of my time. Should be around 1 pm.
- cron: '0 18 * * *'
workflow_dispatch:
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- name: Fetch release version
id: release_version
run: |
curl -sL https://api.github.com/repos/element-hq/synapse/releases/latest | \
echo "release_version=$( jq -r '.tag_name')" >> $GITHUB_OUTPUT
- name: Fetch pre-release version
id: prerelease_version
run: |
curl -sL https://api.github.com/repos/element-hq/synapse/releases | \
echo "prerelease_version=$(jq -r 'map(select(.tag_name)) | first | .tag_name')" >> $GITHUB_OUTPUT
- name: Check recorded versions
id: version_check
shell: bash
run: |
if [ "${{ steps.release_version.outputs.release_version }}" != "$(cat release-versions/synapse-latest.txt)" ]; then
echo "Updating synapse-latest.txt"
echo "${{ steps.release_version.outputs.release_version }}" > release-versions/synapse-latest.txt
fi
if [ "${{ steps.prerelease_version.outputs.prerelease_version }}" != "$(cat release-versions/synapse-prerelease.txt)" ]; then
echo "Updating synapse-prerelease.txt"
echo "${{ steps.prerelease_version.outputs.prerelease_version }}" > release-versions/synapse-prerelease.txt
fi
- name: Check for modified files
id: git-check
run: |
echo "modified=$([ -z `git status --porcelain` ] && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
- name: Commit latest versions
if: ${{ steps.git-check.outputs.modified == 'true' }}
run: |
git config --global user.name 'Jason Little'
git config --global user.email 'realtyem@users.noreply.github.com'
git commit -am "Update Synapse versions(automated)"
git push