-
Notifications
You must be signed in to change notification settings - Fork 34
44 lines (42 loc) · 1.74 KB
/
build-and-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
name: Build and Deploy
on:
push: ~
workflow_dispatch: ~
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container: strongboxci/mkdocs:base
env:
# DEPLOY_URL=https://strongbox.github.io, but it's a "secrets" to allow easier changing if necesary without changing the code.
DEPLOY_URL: "${{ secrets.DEPLOY_URL }}"
GOOGLE_ANALYTICS_KEY: "${{ secrets.GOOGLE_ANALYTICS_KEY }}"
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
- name: Get short SHA
id: slug
run: echo "::set-output name=short_sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
- name: Build
run: mkdocs build
- name: Setup upstream
if: github.ref == 'refs/heads/master'
run: |
git config user.name "${{ secrets.GH_USER }}"
git config user.email "${{ secrets.GH_EMAIL }}"
git remote add strongbox.github.io "https://${{ secrets.GH_TOKEN }}@github.com/strongbox/strongbox.github.io"
git fetch strongbox.github.io
- name: Prepare built assets
if: github.ref == 'refs/heads/master'
run: |
git checkout --orphan gh-pages
find . -maxdepth 1 ! -name "site" ! -name ".git*" ! -name "." -exec git rm -rf {} \;
git add --force site
git commit -m "strongbox/strongbox-docs#${{ steps.slug.outputs.short_sha }}: ${{ github.event.head_commit.message }}"
git log -n 1 --format=oneline
- name: Deploy
if: github.ref == 'refs/heads/master'
run: |
git push strongbox.github.io `git subtree split --prefix site gh-pages`:master --force