-
Notifications
You must be signed in to change notification settings - Fork 3
64 lines (55 loc) · 1.92 KB
/
sync-from-reddit.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
name: Sync from Reddit
on:
workflow_dispatch:
schedule:
# run twice per hour at arbitrary minutes, avoiding busy top of hour
- cron: 17,47 * * * *
jobs:
sync-from-reddit:
name: Sync from Reddit
runs-on: ubuntu-22.04
outputs:
new-commit: ${{ steps.push.outputs.commit }}
permissions:
contents: write
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}
- name: Configure git user
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Setup Python
uses: actions/setup-python@v5
- name: Setup python requirements
run: pip install -r requirements.txt
- name: Download wiki from Reddit
run: python ./download-wiki.py
env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
REDDIT_USER_AGENT: ${{ secrets.REDDIT_USER_AGENT }}
REDDIT_USER_NAME: ${{ secrets.REDDIT_USER_NAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
- name: Push changes (if any)
id: push
run: |
git push
if [ "$GITHUB_SHA" != "$(git rev-parse HEAD)" ]; then
echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
fi
# Pushes from GitHub Actions do not trigger further actions; manually call deploy
deploy:
name: Deploy site
needs: sync-from-reddit
if: "${{ needs.sync-from-reddit.outputs.new-commit != '' }}"
permissions:
contents: write
uses: ./.github/workflows/deploy.yml
with:
new-commit: ${{ needs.sync-from-reddit.outputs.new-commit }}