-
-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (67 loc) · 2.27 KB
/
pages.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
# Workflow to cross-post a jekyll site (or GitHub Pages)
# to another org/repo.
# Required secrets in repository consuming this workflow:
# - PAGES_ORGANIZATION: the target organization to publish
# pages to.
# - PAGES_ACCESS_TOKEN: a token that is valid in the target
# org/repo for pushing the resulting site
# - PAGES_REPOSITORY: optional repository name under the
# target organization. Defaults to source repo name.
name: pages
on:
workflow_dispatch:
push:
branches:
- main
- pages
- docs
env:
PAGES_ORGANIZATION: ${{ secrets.PAGES_ORGANIZATION }}
PAGES_REPOSITORY: ${{ secrets.PAGES_REPOSITORY }}
jobs:
gh-pages:
runs-on: ubuntu-latest
env:
PAGES_ORGANIZATION: ${{ secrets.PAGES_ORGANIZATION }}
PAGES_REPOSITORY: ${{ secrets.PAGES_REPOSITORY }}
PAGES_ACCESS_TOKEN: ${{ secrets.PAGES_ACCESS_TOKEN }}
steps:
- name: ✅ organization
if: env.PAGES_ORGANIZATION == ''
run: |
echo "::error title=PAGES_ORGANIZATION secret is required."
exit 1
- name: ✅ token
if: env.PAGES_ACCESS_TOKEN == ''
run: |
echo "::error title=PAGES_ACCESS_TOKEN secret is required."
exit 1
- name: 🤘 checkout
uses: actions/checkout@v2
- name: ⚙ jekyll
run: |
sudo gem install bundler
sudo bundle install
- name: 🖉 default repo
if: env.PAGES_REPOSITORY == ''
run: echo "PAGES_REPOSITORY=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: 🙏 build
run: bundle exec jekyll build -b ${{ env.PAGES_REPOSITORY }}
env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: ✓ commit
run: |
cd _site
git init
git add -A
git config --local user.email "[email protected]"
git config --local user.name "[email protected]"
git commit -m "Publish pages from ${GITHUB_REPOSITORY}@${GITHUB_SHA:0:9}"
- name: 🚀 push
uses: ad-m/[email protected]
with:
github_token: ${{ env.PAGES_ACCESS_TOKEN }}
repository: ${{ env.PAGES_ORGANIZATION }}/${{ env.PAGES_REPOSITORY }}
branch: gh-pages
force: true
directory: ./_site