-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
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 |