-
Notifications
You must be signed in to change notification settings - Fork 3
108 lines (92 loc) · 3.85 KB
/
deploy.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Deploy Jekyll Site
on:
push:
branches:
- staging
- master
- dp-v1-prod
pull_request:
branches:
- staging
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
# Get system info
- run: ifconfig
- run: sudo dmidecode
- run: df -h
- run: free -m
- run: echo "GitHub branch is ${{ github.ref }}"
# Conditional checkout for PRs
- name: Checkout PR branch
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# Standard checkout for non-PR events
- name: Checkout repo
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
# Install Brotli development headers (Fix for ruby-brs gem)
- name: Install Brotli dependencies
run: sudo apt-get update && sudo apt-get install -y libbrotli-dev
# Build Jekyll Site
- run: echo "Building Jekyll site"
- run: sudo gem install bundler
- run: sudo gem install jekyll
- run: sudo bundle install
- name: Set DP Social URL based on branch
run: |
if [[ "${{ github.ref }}" == "refs/heads/master" ]] || [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "master" ]]; then
sed -i 's|url: "https://social.dp.chanterelle.xyz"|url: "${{ vars.SOCIAL_DP_PROD }}"|' _config.yml
elif [[ "${{ github.ref }}" == "refs/heads/staging" ]] || [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "staging" ]]; then
# Replace with staging URL for activity_pub (SOCIAL_DP_STAGING)
sed -i 's|url: "https://social.dp.chanterelle.xyz"|url: "${{ vars.SOCIAL_DP_STAGING }}"|' _config.yml
fi
# Decode the correct key based on the branch
- name: Decode Staging Key
if: >
github.ref == 'refs/heads/staging' ||
(github.event_name == 'pull_request' && github.base_ref == 'staging')
run: echo ${{ secrets.ENCODED_DP_AP_KEY_STAGING }} | base64 --decode > /tmp/secret.key
- name: Decode Production Key
if: >
github.ref == 'refs/heads/master' ||
(github.event_name == 'pull_request' && github.base_ref == 'master')
run: echo ${{ secrets.ENCODED_DP_AP_KEY_PRODUCTION }} | base64 --decode > /tmp/secret.key
- name: Build Jekyll Site for Staging
if: github.ref == 'refs/heads/staging' || (github.event_name == 'pull_request' && github.base_ref == 'staging')
run: |
JEKYLL_ENV=staging make build-dweb
- name: Build Jekyll Site for Production
if: github.ref == 'refs/heads/master' || (github.event_name == 'pull_request' && github.base_ref == 'master')
run: |
make build-dweb
- run: make check
- name: Publish to Distributed Press Staging
if: ${{ github.ref == 'refs/heads/staging' }}
uses: hyphacoop/[email protected]
with:
publish_dir: _site
dp_url: https://dp.chanterelle.xyz
refresh_token: ${{ secrets.DISTRIBUTED_PRESS_STAGING_TOKEN }}
site_url: staging.hypha.coop
- name: Publish to Distributed Press Production
if: ${{ github.ref == 'refs/heads/master' }}
uses: hyphacoop/[email protected]
with:
publish_dir: _site
dp_url: https://api.distributed.press
refresh_token: ${{ secrets.DISTRIBUTED_PRESS_PRODUCTION_TOKEN}}
site_url: hypha.coop
- name: Notify AP
run: bundle exec jekyll notify --key /tmp/secret.key --verbose --trace
- name: Commit ActivityPub Data
uses: EndBug/add-and-commit@v9
with:
add: '_data/activity_pub.yml'
default_author: github_actions
message: 'Commit ActivityPub Data'
fetch: true