1313jobs :
1414 publish :
1515 runs-on : ubuntu-latest
16+ outputs :
17+ has_new_content : ${{ steps.check_changes.outputs.content }}
1618 steps :
1719 - name : Checkout
1820 uses : actions/checkout@v4
21+ - name : Check for news/events content changes
22+ uses : dorny/paths-filter@v3
23+ id : check_changes
24+ with :
25+ list-files : json
26+ filters : |
27+ content:
28+ - added: 'content/news/**/index.md'
29+ - added: 'content/events/**/index.md'
1930 - name : Setup node
2031 uses : actions/setup-node@v4
2132 with :
@@ -34,70 +45,26 @@ jobs:
3445 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3546 AWS_REGION : " us-east-2" # optional: defaults to us-east-1
3647 SOURCE_DIR : " dist" # optional: defaults to entire repository
48+ - name : Invalidate CloudFront cache for feeds
49+ if : steps.check_changes.outputs.content == 'true'
50+ env :
51+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
52+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
53+ AWS_REGION : " us-east-1"
54+ run : |
55+ aws cloudfront create-invalidation \
56+ --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
57+ --paths "/events/feed.json" "/news/feed.json"
58+ - name : Wait for cache invalidation
59+ if : steps.check_changes.outputs.content == 'true'
60+ run : sleep 90
3761
3862 galaxy-social-assistant :
3963 needs : publish
40- if : github.event_name == 'push'
64+ if : github.event_name == 'push' && needs.publish.outputs.has_new_content == 'true'
4165 runs-on : ubuntu-latest
4266 steps :
43- - name : Checkout
44- uses : actions/checkout@v4
45- - name : Check for news/events content changes
46- uses : dorny/paths-filter@v3
47- id : check_changes
48- with :
49- list-files : json
50- filters : |
51- content:
52- - added: 'content/news/**/index.md'
53- - added: 'content/events/**/index.md'
54- - name : Wait for updated feeds to be available
55- if : steps.check_changes.outputs.content == 'true'
56- shell : python
57- run : |
58- import json
59- import re
60- import time
61- import urllib.request
62-
63- files = json.loads("${{ steps.check_changes.outputs.content_files }}")
64- print(f"Checking {len(files)} new posts in feeds...")
65-
66- timeout = 3600
67- start_time = time.time()
68- wait_time = 10.0
69-
70- while time.time() - start_time < timeout:
71- try:
72- all_found = True
73- for file in files:
74- match = re.match(r"content/(news|events)/([^/]+)/", file)
75- if not match:
76- print(f"Skipping invalid file path: {file}")
77- continue
78- feed_type, dir_name = match.groups()
79- req = urllib.request.Request(
80- f"https://galaxyproject.org/{feed_type}/feed.json"
81- )
82- with urllib.request.urlopen(req, timeout=30) as response:
83- feed = json.load(response)
84- if not any(
85- f"/{feed_type}/{dir_name}/" in item["path"] for item in feed[feed_type]
86- ):
87- print(f"Waiting for /{feed_type}/{dir_name}/")
88- all_found = False
89- break
90- if all_found:
91- print("All content found in feeds!")
92- exit(0)
93- except Exception as e:
94- print(f"Error fetching feed: {e}")
95- time.sleep(wait_time)
96- wait_time = min(wait_time * 1.5, 300.0)
97- print("Timeout waiting for feeds")
98- exit(1)
9967 - name : Create Galaxy Social Assistant Token
100- if : steps.check_changes.outputs.content == 'true'
10168 uses : actions/create-github-app-token@v2
10269 id : galaxy-social-assistant-token
10370 with :
@@ -106,10 +73,10 @@ jobs:
10673 owner : " usegalaxy-eu"
10774 repositories : " galaxy-social-assistant"
10875 - name : Trigger Galaxy Social Assistant
109- if : steps.check_changes.outputs.content == 'true'
11076 uses : benc-uk/workflow-dispatch@v1
11177 with :
11278 workflow : feed_bot.yml
11379 repo : usegalaxy-eu/galaxy-social-assistant
11480 token : ${{ steps.galaxy-social-assistant-token.outputs.token }}
11581 ref : main
82+ inputs : ' {"days": "1"}'
0 commit comments