-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (60 loc) · 2.22 KB
/
check-releases.yml
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
name: Check for New Releases
on:
schedule:
- cron: "0 0 * * *" # Runs every hour
workflow_dispatch:
jobs:
check_and_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Check for new Photon release
id: check_release
run: |
latest_release=$(curl -s https://github.com/komoot/photon/releases.atom | grep '<title>' | sed -n '2p' | sed -E 's/.*Release ([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
echo "latest_release=${latest_release}" >> "$GITHUB_ENV"
- name: Get last processed release
id: get_last_release
run: |
echo "last_release=$(cat .last_release)" >> "$GITHUB_ENV"
continue-on-error: true
- name: Create Release
if: env.latest_release != env.last_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.latest_release }}
name: Release ${{ env.latest_release }}
body: |
New Photon release: ${{ env.latest_release }}
This is an automated release created by the GitHub Actions workflow.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.MY_PAT_TOKEN }}
- name: Update last release file
if: env.latest_release != env.last_release
run: |
echo "${latest_release}" > .last_release
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .last_release
git commit -m "Update last processed release to ${latest_release}"
git push --force
- name: Trigger build workflow
if: env.latest_release != env.last_release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.MY_PAT_TOKEN }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-and-push.yml',
ref: 'main',
inputs: {
release_tag: '${{ env.latest_release }}'
}
})