forked from galaxyproject/training-material
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (65 loc) · 2.45 KB
/
social.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
69
70
71
72
73
name: "[Social] Autogenerate missing social media cards"
on:
schedule:
# * is a special character in YAML so you have to quote this string
# We'll run this weekly at noon.
- cron: '0 12 * * 0'
workflow_dispatch:
inputs:
all_old:
type: string
description: If you want to re-generate ALL images set to a non-empty value
jobs:
runner-job:
if: github.repository_owner == 'galaxyproject'
runs-on: ubuntu-latest
steps:
# Shallow should be fine for video
- uses: actions/checkout@v4
with:
fetch-depth: 500
# BEGIN Dependencies
- uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: 'x64'
- name: Install dependencies
run: |
sudo apt-get install -y imagemagick optipng
pip install requests awscli
mkdir -p ~/.fonts/
wget https://galaxy-training.s3.amazonaws.com/social/recursive.ttf -O ~/.fonts/recursive.ttf
fc-cache -rv
# END Dependencies
# We get the previous build ID to know how many videos were changed since
# then.
#
# We *could* fetch the diff in the past N days but if a build fails for
# any reason, we'd lose those changes permanently and things would never
# get built.
#
# So instead we just track the last successfully built timestamp
- name: Previous build ID
id: build_id
run: |
echo "timestamp=$(curl https://galaxy-training.s3.amazonaws.com/social/timestamp.txt -f 2>/dev/null || echo none)" >> $GITHUB_ENV
# Support regenerating all
if [[ "${{ github.event.inputs.selected_tag }}" != "" ]]; then
echo "timestamp=0" >> $GITHUB_ENV
fi
# The actual compilation process deposits everything in the ./social/ folder.
# And requires fetching metadata from the live website (api/social-meta.json)
- name: Build Social Media Cards
run: |
mkdir -p social/
python bin/social-cards.py $PREVIOUS_TIMESTAMP
env:
PREVIOUS_TIMESTAMP: ${{ env.timestamp }}
# Deploy step, scary.
- name: Build Social Media Cards
run: |
aws s3 cp --recursive ../gtn-social/ s3://galaxy-training/social/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1